From: Jason Merrill Date: Sat, 15 Nov 2025 17:43:37 +0000 (+0530) Subject: c++/modules: explicit inst of constructor X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c38bf35f0c7fa1dadaae4c2811b24aa4cd764cab;p=thirdparty%2Fgcc.git c++/modules: explicit inst of constructor The extern template __shared_ptr in bits/fs_dir.h was leading to an ICE in import_export_decl in 29_atomics/atomic_ref/address.cc because we had the nonsensical combination of DECL_REALLY_EXTERN and !DECL_INTERFACE_KNOWN. This turned out to be because mark_decl_instantiated was exiting early if TREE_ASM_WRITTEN since way back in the pre-cgraph days, and expand_or_defer_fn_1 sets TREE_ASM_WRITTEN on maybe-in-charge ctors. The mark_decl_instantiated code is long-obsolete, so let's just remove it. gcc/cp/ChangeLog: * module.cc (trees_out::write_function_def): Check flag consistency. * pt.cc (mark_decl_instantiated): Ignore TREE_ASM_WRITTEN. --- diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 45a0309b86e..48ee7d1e790 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -12914,6 +12914,13 @@ trees_out::write_function_def (tree decl) && (get_importer_interface (decl) != importer_interface::external)); + /* Make sure DECL_REALLY_EXTERN and DECL_INTERFACE_KNOWN are consistent + on non-templates or we'll crash later in import_export_decl. */ + gcc_checking_assert (flags || DECL_INTERFACE_KNOWN (decl) + || (DECL_LANG_SPECIFIC (decl) + && DECL_TEMPLATE_INFO (decl) + && uses_template_parms (DECL_TI_ARGS (decl)))); + if (f) { flags |= 2; diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index b10442b0960..3b581b3fd36 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -26379,11 +26379,6 @@ mark_decl_instantiated (tree result, int extern_p) { SET_DECL_EXPLICIT_INSTANTIATION (result); - /* If this entity has already been written out, it's too late to - make any modifications. */ - if (TREE_ASM_WRITTEN (result)) - return; - /* consteval functions are never emitted. */ if (TREE_CODE (result) == FUNCTION_DECL && DECL_IMMEDIATE_FUNCTION_P (result))