https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96690
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|c++ |debug Keywords| |ice-on-valid-code --- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- Hmm, but we're pushing TYPE_MAIN_VARIANT (). The issue seems to be that we're mangling 'foo' via rtl_for_decl_init () which is the init of a template value, &foo, that is only required from debug and FLD does not walk those template trees we eventually generate this debug from. That said, we're expecting to have mangled everything we have to eventually mangle at the time FLD runs but here we're mangling things after the fact. IMHO the template paramter DIE should have a more symbolic representation and not use relocations to say 'foo'. Trying to bypass rtl_for_decl_init via diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 9deca031fc2..4d652e594ad 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -19764,6 +19793,9 @@ reference_to_unused (tree * tp, int * walk_subtrees, if (!node || !node->definition) return *tp; } + else if (TREE_CODE (*tp) == FUNCTION_DECL + && !DECL_ASSEMBLER_NAME_SET_P (*tp)) + return *tp; else if (TREE_CODE (*tp) == FUNCTION_DECL && (!DECL_EXTERNAL (*tp) || DECL_DECLARED_INLINE_P (*tp))) { turns this into the very same issue via 0xfe0d36 cst_pool_loc_descr ../../src/gcc/gcc/dwarf2out.c:17485 0xfe21e9 loc_list_from_tree_1 ../../src/gcc/gcc/dwarf2out.c:18305 0xfe4823 loc_list_from_tree ../../src/gcc/gcc/dwarf2out.c:19042 0xfe4881 loc_descriptor_from_tree ../../src/gcc/gcc/dwarf2out.c:19055 0xffb29d gen_remaining_tmpl_value_param_die_attribute ../../src/gcc/gcc/dwarf2out.c:27168 where loc_list_from_tree_1 doesn't seem to have the same "protection" against referencing unused symbols as rtl_for_decl_init has. Note without -flto we do not appear to output a DIE refering to 'foo'.