https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109232
Patrick Palka <ppalka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ppalka at gcc dot gnu.org --- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> --- What seems to be happening is determine_visibility correctly notices that begin<R> should have internal linkage due to R having internal linkage, so it proceeds to clear TREE_PUBLIC, DECL_COMDAT, DECL_EXTERN, etc for begin<R>. Later in cgraph_node::finalize for begin<R>, we force its definition to be outputted due to /* When not optimizing, also output the static functions. (see PR24561), but don't do so for always_inline functions, functions declared inline and nested functions. These were optimized out in the original implementation and it is unclear whether we want to change the behavior here. */ if (((!opt_for_fn (decl, optimize) || flag_keep_static_functions || node->no_reorder) && !node->cpp_implicit_alias && !DECL_DISREGARD_INLINE_LIMITS (decl) && !DECL_DECLARED_INLINE_P (decl) && !(DECL_CONTEXT (decl) && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL)) && !DECL_COMDAT (decl) && !DECL_EXTERNAL (decl)) node->force_output = 1; I guess we need to somehow refine the above test to exclude implicit instantiations with internal linkage?