https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65549
--- Comment #23 from Richard Biener <rguenth at gcc dot gnu.org> --- When doing LTO early-debug work I stumbled over one reason we can crash here which I fixed with Index: dwarf2out.c =================================================================== *** dwarf2out.c (revision 222165) --- dwarf2out.c (working copy) *************** resolve_addr (dw_die_ref die) *** 23950,23957 **** && DECL_EXTERNAL (tdecl) && DECL_ABSTRACT_ORIGIN (tdecl) == NULL_TREE) { ! force_decl_die (tdecl); ! tdie = lookup_decl_die (tdecl); } if (tdie) { --- 23950,23964 ---- && DECL_EXTERNAL (tdecl) && DECL_ABSTRACT_ORIGIN (tdecl) == NULL_TREE) { ! /* Creating a full DIE for tdecl is overly expensive and ! at this point (with early debug active) even wrong ! as it can end up generating new type DIEs we didn't ! output. */ ! tdie = new_die (DW_TAG_subprogram, comp_unit_die (), NULL_TREE); ! add_AT_flag (tdie, DW_AT_external, 1); ! add_AT_flag (tdie, DW_AT_declaration, 1); ! add_linkage_attr (tdie, tdecl); ! equate_decl_number_to_die (tdecl, tdie); } if (tdie) { change the comment to "at this point (with LTO) even wrong" and it still applies. The point is, if we didn't create a DIE for the external decl it isn't a good idea to create a full DIE for it for the reference. Just create a DIE with enough info for the debugger (I suppose that's the linkage name? I really didn't check whether that's ok for the purpose of DW_TAG_GNU_call_site - Jakub? (not sure if we have guality checks that cover this very case) ISTR that for the case I ran into the call was to some builtin function. The above patch fixes this bug.