https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120125
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-15 branch has been updated by Nathaniel Shead <nsh...@gcc.gnu.org>: https://gcc.gnu.org/g:6dfc5d1fc86fe6aaed6e7c476286f7a5f0ffc867 commit r15-9681-g6dfc5d1fc86fe6aaed6e7c476286f7a5f0ffc867 Author: Nathaniel Shead <nathanielosh...@gmail.com> Date: Thu May 8 23:06:13 2025 +1000 c++/modules: Fix handling of -fdeclone-ctor-dtor with explicit instantiations [PR120125] The attached testcase ICEs in maybe_thunk_body because we haven't created a node in the cgraph for an imported explicit instantiation yet. We in fact really shouldn't be emitting calls at all, since an imported explicit instantiation always exists in the TU we imported it from. So this patch adjusts DECL_NOT_REALLY_EXTERN handling to account for this. PR c++/120125 gcc/cp/ChangeLog: * module.cc (trees_out::write_function_def): Only set DECL_NOT_REALLY_EXTERN if the importer might need to emit it. * optimize.cc (maybe_thunk_body): Don't assume 'fn' has a cgraph node created. gcc/testsuite/ChangeLog: * g++.dg/modules/clone-4_a.C: New test. * g++.dg/modules/clone-4_b.C: New test. Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com> Reviewed-by: Jason Merrill <ja...@redhat.com> (cherry picked from commit d787bc4fd372298e9ed5b11cb3050fd3707070f6)