https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86523
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2018-07-16 Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Martin Liška from comment #1) > One more test-case with a bit different BT: > > $ cat ice.ii > namespace { > class a typedef b; > class a {}; > } // namespace > class c { > struct C { > b d; > }; > C e() const; > }; > c::C c::e() const { > C g; > struct h { > C g; > h(C *) {} > } f(&g); > } > > $ g++ ice.ii -O2 -flto=8 -g -shared > ice.ii: In member function ‘c::C c::e() const’: > ice.ii:17:1: warning: no return statement in function returning non-void > [-Wreturn-type] > } > ^ > > lto1: internal compiler error: in dwarf2out_finish, at dwarf2out.c:31107 > 0x5c87cd dwarf2out_finish > /home/marxin/Programming/gcc/gcc/dwarf2out.c:31107 > Please submit a full bug report, > with preprocessed source if appropriate. > Please include the complete backtrace with any bug report. > See <https://gcc.gnu.org/bugs/> for instructions. > make: *** [/tmp/cc5TI8Oi.mk:2: /tmp/ccQqbTv7.ltrans0.ltrans.o] Error 1 > lto-wrapper: fatal error: make returned 2 exit status > compilation terminated. > /usr/bin/ld: error: lto-wrapper failed > collect2: error: ld returned 1 exit status We generate a DECL_ASSEMBLER_NAME for <type_decl 0x7ffff6a822f8 b> through #0 0x00000000009e1269 in add_linkage_name_raw ( die=<dw_die_ref 0x7ffff6a85af0 DW_TAG_structure_type <parent=0x7ffff6a850f0 DW_TAG_namespace>>, decl=<type_decl 0x7ffff6a822f8 b>) at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:21233 #1 0x00000000009ec5df in gen_typedef_die (decl=<type_decl 0x7ffff6a822f8 b>, context_die=<dw_die_ref 0x7ffff6a850f0 DW_TAG_namespace <parent=0x7ffff6a85000 DW_TAG_compile_unit>>) at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:25251 #2 0x00000000009ef609 in gen_decl_die (decl=<type_decl 0x7ffff6a822f8 b>, origin=<tree 0x0>, ctx=0x0, context_die=<dw_die_ref 0x7ffff6a850f0 DW_TAG_namespace <parent=0x7ffff6a85000 DW_TAG_compile_unit>>) at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:26229 #3 0x00000000009ecd95 in gen_type_die_with_usage ( type=<record_type 0x7ffff6a863f0 b>, context_die=<dw_die_ref 0x7ffff6a850f0 DW_TAG_namespace <parent=0x7ffff6a85000 DW_TAG_compile_unit>>, usage=DINFO_USAGE_DIR_USE) at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:25394 #4 0x00000000009ed695 in gen_type_die (type=<record_type 0x7ffff6a863f0 b>, context_die=<dw_die_ref 0x7ffff6a85a50 DW_TAG_structure_type <parent=0x7ffff6a85a00 DW_TAG_structure_type>>) at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:25578 #5 0x00000000009ef8c6 in gen_decl_die (decl=<field_decl 0x7ffff6a82390 d>, origin=<tree 0x0>, ctx=0x7fffffffcdc0, context_die=<dw_die_ref 0x7ffff6a85a50 DW_TAG_structure_type <parent=0x7ffff6a85a00 DW_TAG_structure_type>>) at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:26297 #6 0x00000000009eb81f in gen_member_die (type=<record_type 0x7ffff6a86498 C>, context_die=<dw_die_ref 0x7ffff6a85a50 DW_TAG_structure_type <parent=0x7ffff6a85a00 DW_TAG_structure_type>>) at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:25032 #7 0x00000000009ebf69 in gen_struct_or_union_type_die ( type=<record_type 0x7ffff6a86498 C>, context_die=<dw_die_ref 0x7ffff6a85a00 DW_TAG_structure_type <parent=0x7ffff6a85000 DW_TAG_compile_unit>>, usage=DINFO_USAGE_DIR_USE) at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:25128 #8 0x00000000009eca10 in gen_tagged_type_die ( type=<record_type 0x7ffff6a86498 C>, context_die=<dw_die_ref 0x7ffff6a85a00 DW_TAG_structure_type <parent=0x7ffff6a85000 DW_TAG_compile_unit>>, usage=DINFO_USAGE_DIR_USE) at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:25329 #9 0x00000000009ed321 in gen_type_die_with_usage ( type=<record_type 0x7ffff6a86498 C>, context_die=<dw_die_ref 0x7ffff6a859b0 DW_TAG_structure_type <parent=0x7ffff6a85190 DW_TAG_subprogram>>, usage=DINFO_USAGE_DIR_USE) at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:25524 ... #18 0x00000000009eea5f in force_type_die (type=<record_type 0x7ffff6a867e0 h>) at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:25973 #19 0x00000000009ee6d7 in get_context_die ( context=<record_type 0x7ffff6a867e0 h>) at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:25888 #20 0x00000000009fa4c9 in flush_limbo_die_list () at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:31053 #21 0x00000000009fa5dc in dwarf2out_finish () at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:31093 where the limbo DIE is $8 = {die = <dw_die_ref 0x7ffff6a852d0 DW_TAG_subprogram>, created_for = <function_decl 0x7ffff6a81e00 __ct_base >, next = 0x7ffff6a7c510} DIE 0: DW_TAG_subprogram (0x7ffff6a852d0) abbrev id: 0 offset: 0 mark: 0 DW_AT_abstract_origin: die -> label: t.ii.e437cd39 + 316 (0x7ffff6a85320) so the issue here is that the context is a RECORD_TYPE which context is $12 = <function_decl 0x7ffff6a81b00 e> but at the time of dwarf2out_register_external_die it isn't assigned the proper parent. So the real bug is that we do this "inclusive": else if (TREE_CODE (ctx) == FUNCTION_DECL && TREE_CODE (decl) != PARM_DECL && TREE_CODE (decl) != BLOCK) /* Leave function local entities parent determination to when we process scope vars. */ ; including != FUNCTION_DECL makes both testcases work, another somewhat obvious addition would be RESULT_DECL.