https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79129
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Adjusted testcase: struct A { void foo (int &); }; struct B { A *bar (); ~B () { int a = 1; bar ()->foo (a); } }; struct C { ~C (); B c; }; C::~C () {} doesn't ICE. On this testcase, the difference between print_die (comp_unit_die (), stderr) before and after the break_out_comdat_types (comp_unit_die ()); call gives: --- 1 2017-01-18 17:24:43.363049681 +0100 +++ 2 2017-01-18 17:25:03.509787874 +0100 @@ -4,12 +4,12 @@ DIE 0: DW_TAG_compile_unit (0x7fffefa DW_AT_language: 4 DW_AT_name: "pr79129-2.C" DW_AT_comp_dir: "/usr/src/gcc/obj/gcc" - DIE 0: DW_TAG_structure_type (0x7fffefaea050) + DIE 0: DW_TAG_structure_type (0x7fffefaeaeb0) abbrev id: 0 offset: 0 mark: 0 + signature: 798cbb933baaec2c DW_AT_name: "A" - DW_AT_byte_size: 1 - DW_AT_decl_file: "pr79129-2.C" (0) - DW_AT_decl_line: 1 + DW_AT_signature: die -> signature: 798cbb933baaec2c (0x7fffefaea050) + DW_AT_declaration: 1 DIE 0: DW_TAG_subprogram (0x7fffefaea0a0) abbrev id: 0 offset: 0 mark: 0 DW_AT_external: 1 @@ -18,18 +18,10 @@ DIE 0: DW_TAG_compile_unit (0x7fffefa DW_AT_decl_line: 1 DW_AT_linkage_name: "_ZN1A3fooERi" DW_AT_declaration: 1 - DW_AT_object_pointer: die -> 0 (0x7fffefaea0f0) - DIE 0: DW_TAG_formal_parameter (0x7fffefaea0f0) - abbrev id: 0 offset: 0 mark: 0 - DW_AT_type: die -> 0 (0x7fffefaea140) - DW_AT_artificial: 1 - DIE 0: DW_TAG_formal_parameter (0x7fffefaea190) - abbrev id: 0 offset: 0 mark: 0 - DW_AT_type: die -> 0 (0x7fffefaea1e0) DIE 0: DW_TAG_pointer_type (0x7fffefaea140) abbrev id: 0 offset: 0 mark: 0 DW_AT_byte_size: 8 - DW_AT_type: die -> 0 (0x7fffefaea050) + DW_AT_type: die -> signature: 798cbb933baaec2c (0x7fffefaea050) DIE 0: DW_TAG_reference_type (0x7fffefaea1e0) abbrev id: 0 offset: 0 mark: 0 DW_AT_byte_size: 8 @@ -42,12 +34,12 @@ DIE 0: DW_TAG_compile_unit (0x7fffefa DIE 0: DW_TAG_const_type (0x7fffefaeaa00) abbrev id: 0 offset: 0 mark: 0 DW_AT_type: die -> 0 (0x7fffefaea230) - DIE 0: DW_TAG_structure_type (0x7fffefaea280) + DIE 0: DW_TAG_structure_type (0x7fffefaeafa0) abbrev id: 0 offset: 0 mark: 0 + signature: a6d1580689de2b0b DW_AT_name: "B" - DW_AT_byte_size: 1 - DW_AT_decl_file: "pr79129-2.C" (0) - DW_AT_decl_line: 2 + DW_AT_signature: die -> signature: a6d1580689de2b0b (0x7fffefaea280) + DW_AT_declaration: 1 DIE 0: DW_TAG_subprogram (0x7fffefaea2d0) abbrev id: 0 offset: 0 mark: 0 DW_AT_external: 1 @@ -57,11 +49,6 @@ DIE 0: DW_TAG_compile_unit (0x7fffefa DW_AT_linkage_name: "_ZN1B3barEv" DW_AT_type: die -> 0 (0x7fffefaea140) DW_AT_declaration: 1 - DW_AT_object_pointer: die -> 0 (0x7fffefaea320) - DIE 0: DW_TAG_formal_parameter (0x7fffefaea320) - abbrev id: 0 offset: 0 mark: 0 - DW_AT_type: die -> 0 (0x7fffefaea370) - DW_AT_artificial: 1 DIE 0: DW_TAG_subprogram (0x7fffefaea3c0) abbrev id: 0 offset: 0 mark: 0 DW_AT_external: 1 @@ -70,35 +57,19 @@ DIE 0: DW_TAG_compile_unit (0x7fffefa DW_AT_decl_line: 5 DW_AT_linkage_name: "_ZN1BD4Ev" DW_AT_declaration: 1 - DW_AT_object_pointer: die -> 0 (0x7fffefaea410) - DIE 0: DW_TAG_formal_parameter (0x7fffefaea410) - abbrev id: 0 offset: 0 mark: 0 - DW_AT_type: die -> 0 (0x7fffefaea370) - DW_AT_artificial: 1 - DIE 0: DW_TAG_formal_parameter (0x7fffefaea460) - abbrev id: 0 offset: 0 mark: 0 - DW_AT_type: die -> 0 (0x7fffefaea230) - DW_AT_artificial: 1 DIE 0: DW_TAG_pointer_type (0x7fffefaea370) abbrev id: 0 offset: 0 mark: 0 DW_AT_byte_size: 8 - DW_AT_type: die -> 0 (0x7fffefaea280) + DW_AT_type: die -> signature: a6d1580689de2b0b (0x7fffefaea280) DIE 0: DW_TAG_const_type (0x7fffefaeab90) abbrev id: 0 offset: 0 mark: 0 DW_AT_type: die -> 0 (0x7fffefaea370) - DIE 0: DW_TAG_structure_type (0x7fffefaea4b0) + DIE 0: DW_TAG_structure_type (0x7fffefc580f0) abbrev id: 0 offset: 0 mark: 0 + signature: ecf81ca311705bbd DW_AT_name: "C" - DW_AT_byte_size: 1 - DW_AT_decl_file: "pr79129-2.C" (0) - DW_AT_decl_line: 7 - DIE 0: DW_TAG_member (0x7fffefaea500) - abbrev id: 0 offset: 0 mark: 0 - DW_AT_name: "c" - DW_AT_decl_file: "pr79129-2.C" (0) - DW_AT_decl_line: 7 - DW_AT_type: die -> 0 (0x7fffefaea280) - DW_AT_data_member_location: 0 + DW_AT_signature: die -> signature: ecf81ca311705bbd (0x7fffefaea4b0) + DW_AT_declaration: 1 DIE 0: DW_TAG_subprogram (0x7fffefaea550) abbrev id: 0 offset: 0 mark: 0 DW_AT_external: 1 @@ -107,19 +78,10 @@ DIE 0: DW_TAG_compile_unit (0x7fffefa DW_AT_decl_line: 7 DW_AT_linkage_name: "_ZN1CD4Ev" DW_AT_declaration: 1 - DW_AT_object_pointer: die -> 0 (0x7fffefaea5a0) - DIE 0: DW_TAG_formal_parameter (0x7fffefaea5a0) - abbrev id: 0 offset: 0 mark: 0 - DW_AT_type: die -> 0 (0x7fffefaea5f0) - DW_AT_artificial: 1 - DIE 0: DW_TAG_formal_parameter (0x7fffefaea640) - abbrev id: 0 offset: 0 mark: 0 - DW_AT_type: die -> 0 (0x7fffefaea230) - DW_AT_artificial: 1 DIE 0: DW_TAG_pointer_type (0x7fffefaea5f0) abbrev id: 0 offset: 0 mark: 0 DW_AT_byte_size: 8 - DW_AT_type: die -> 0 (0x7fffefaea4b0) + DW_AT_type: die -> signature: ecf81ca311705bbd (0x7fffefaea4b0) DIE 0: DW_TAG_const_type (0x7fffefaea960) abbrev id: 0 offset: 0 mark: 0 DW_AT_type: die -> 0 (0x7fffefaea5f0) (i.e. before pruning unused stuff) which looks reasonable to me, the three DW_TAG_structure_type DIEs are moved into their own .debug_types units together with copies of other needed DIEs, while all other DIEs that should stay stayed in the CU, just those 3 DW_TAG_structure_type DIEs were moved were replaced with copies. Just wonder what would happen if anything referred to the DW_TAG_formal_parameter DIEs in the main CU, but as it is external, it is unlikely. But with the #c0 testcase the diff is: --- 3 2017-01-18 18:45:12.125590423 +0100 +++ 4 2017-01-18 18:45:32.779325191 +0100 @@ -4,34 +4,18 @@ DIE 0: DW_TAG_compile_unit (0x7fffefa DW_AT_language: 4 DW_AT_name: "pr79129.C" DW_AT_comp_dir: "/usr/src/gcc/obj/gcc" - DIE 0: DW_TAG_structure_type (0x7fffefaea050) + DIE 0: DW_TAG_structure_type (0x7fffefc58050) abbrev id: 0 offset: 0 mark: 0 + signature: ce3fbc5d394db0b1 DW_AT_name: "B" - DW_AT_byte_size: 1 - DW_AT_decl_file: "pr79129.C" (0) - DW_AT_decl_line: 1 - DIE 0: DW_TAG_structure_type (0x7fffefaea0a0) + DW_AT_signature: die -> signature: ce3fbc5d394db0b1 (0x7fffefaea050) + DW_AT_declaration: 1 + DIE 0: DW_TAG_structure_type (0x7fffefaeaf00) abbrev id: 0 offset: 0 mark: 0 + signature: 1e451c7e817570b9 DW_AT_name: "A" - DW_AT_byte_size: 1 - DW_AT_decl_file: "pr79129.C" (0) - DW_AT_decl_line: 3 - DIE 0: DW_TAG_subprogram (0x7fffefaea0f0) - abbrev id: 0 offset: 0 mark: 0 - DW_AT_external: 1 - DW_AT_name: "foo" - DW_AT_decl_file: "pr79129.C" (0) - DW_AT_decl_line: 3 - DW_AT_linkage_name: "_ZN1B1A3fooERi" - DW_AT_declaration: 1 - DW_AT_object_pointer: die -> 0 (0x7fffefaea140) - DIE 0: DW_TAG_formal_parameter (0x7fffefaea140) - abbrev id: 0 offset: 0 mark: 0 - DW_AT_type: die -> 0 (0x7fffefaea190) - DW_AT_artificial: 1 - DIE 0: DW_TAG_formal_parameter (0x7fffefaea1e0) - abbrev id: 0 offset: 0 mark: 0 - DW_AT_type: die -> 0 (0x7fffefaea230) + DW_AT_declaration: 1 + DW_AT_signature: die -> signature: 1e451c7e817570b9 (0x7fffefaea0a0) DIE 0: DW_TAG_subprogram (0x7fffefaea2d0) abbrev id: 0 offset: 0 mark: 0 DW_AT_external: 1 @@ -41,11 +25,6 @@ DIE 0: DW_TAG_compile_unit (0x7fffefa DW_AT_linkage_name: "_ZN1B3barEv" DW_AT_type: die -> 0 (0x7fffefaea190) DW_AT_declaration: 1 - DW_AT_object_pointer: die -> 0 (0x7fffefaea320) - DIE 0: DW_TAG_formal_parameter (0x7fffefaea320) - abbrev id: 0 offset: 0 mark: 0 - DW_AT_type: die -> 0 (0x7fffefaea370) - DW_AT_artificial: 1 DIE 0: DW_TAG_subprogram (0x7fffefaea3c0) abbrev id: 0 offset: 0 mark: 0 DW_AT_external: 1 @@ -54,19 +33,10 @@ DIE 0: DW_TAG_compile_unit (0x7fffefa DW_AT_decl_line: 5 DW_AT_linkage_name: "_ZN1BD4Ev" DW_AT_declaration: 1 - DW_AT_object_pointer: die -> 0 (0x7fffefaea410) - DIE 0: DW_TAG_formal_parameter (0x7fffefaea410) - abbrev id: 0 offset: 0 mark: 0 - DW_AT_type: die -> 0 (0x7fffefaea370) - DW_AT_artificial: 1 - DIE 0: DW_TAG_formal_parameter (0x7fffefaea460) - abbrev id: 0 offset: 0 mark: 0 - DW_AT_type: die -> 0 (0x7fffefaea280) - DW_AT_artificial: 1 DIE 0: DW_TAG_pointer_type (0x7fffefaea190) abbrev id: 0 offset: 0 mark: 0 DW_AT_byte_size: 8 - DW_AT_type: die -> 0 (0x7fffefaea0a0) + DW_AT_type: die -> signature: 1e451c7e817570b9 (0x7fffefaea0a0) DIE 0: DW_TAG_reference_type (0x7fffefaea230) abbrev id: 0 offset: 0 mark: 0 DW_AT_byte_size: 8 @@ -82,23 +52,16 @@ DIE 0: DW_TAG_compile_unit (0x7fffefa DIE 0: DW_TAG_pointer_type (0x7fffefaea370) abbrev id: 0 offset: 0 mark: 0 DW_AT_byte_size: 8 - DW_AT_type: die -> 0 (0x7fffefaea050) + DW_AT_type: die -> signature: ce3fbc5d394db0b1 (0x7fffefaea050) DIE 0: DW_TAG_const_type (0x7fffefaeab90) abbrev id: 0 offset: 0 mark: 0 DW_AT_type: die -> 0 (0x7fffefaea370) - DIE 0: DW_TAG_structure_type (0x7fffefaea4b0) + DIE 0: DW_TAG_structure_type (0x7fffefc581e0) abbrev id: 0 offset: 0 mark: 0 + signature: 8f3220878371d9fb DW_AT_name: "C" - DW_AT_byte_size: 1 - DW_AT_decl_file: "pr79129.C" (0) - DW_AT_decl_line: 7 - DIE 0: DW_TAG_member (0x7fffefaea500) - abbrev id: 0 offset: 0 mark: 0 - DW_AT_name: "c" - DW_AT_decl_file: "pr79129.C" (0) - DW_AT_decl_line: 7 - DW_AT_type: die -> 0 (0x7fffefaea050) - DW_AT_data_member_location: 0 + DW_AT_signature: die -> signature: 8f3220878371d9fb (0x7fffefaea4b0) + DW_AT_declaration: 1 DIE 0: DW_TAG_subprogram (0x7fffefaea550) abbrev id: 0 offset: 0 mark: 0 DW_AT_external: 1 @@ -107,19 +70,10 @@ DIE 0: DW_TAG_compile_unit (0x7fffefa DW_AT_decl_line: 7 DW_AT_linkage_name: "_ZN1CD4Ev" DW_AT_declaration: 1 - DW_AT_object_pointer: die -> 0 (0x7fffefaea5a0) - DIE 0: DW_TAG_formal_parameter (0x7fffefaea5a0) - abbrev id: 0 offset: 0 mark: 0 - DW_AT_type: die -> 0 (0x7fffefaea5f0) - DW_AT_artificial: 1 - DIE 0: DW_TAG_formal_parameter (0x7fffefaea640) - abbrev id: 0 offset: 0 mark: 0 - DW_AT_type: die -> 0 (0x7fffefaea280) - DW_AT_artificial: 1 DIE 0: DW_TAG_pointer_type (0x7fffefaea5f0) abbrev id: 0 offset: 0 mark: 0 DW_AT_byte_size: 8 - DW_AT_type: die -> 0 (0x7fffefaea4b0) + DW_AT_type: die -> signature: 8f3220878371d9fb (0x7fffefaea4b0) DIE 0: DW_TAG_const_type (0x7fffefaea960) abbrev id: 0 offset: 0 mark: 0 DW_AT_type: die -> 0 (0x7fffefaea5f0) and as you can see, all the children of the DW_TAG_structure_type "A" were just moved into the .debug_types unit, instead of copied.