https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86321
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- So in the end the issue is we have two record_types, record_type 0x7ffff6a8dc78 array01_integer(kind=4) and record_type 0x7ffff6a8de70 array01_a which are their own TYPE_MAIN_VARIANT but share TYPE_FIELDS. The FIELD_DECL has a DECL_CONTEXT of yet another type, record_type 0x7ffff6a8dbd0 array_descriptor01 (this is the TYPE_CANONICAL of all the types). This is already wrecked during LTO stream-out: Breakpoint 5, write_ts_type_non_common_tree_pointers (ob=0x2d15ce0, expr=<record_type 0x7ffff6a55498 array_descriptor01>, ref_p=false) at /tmp/trunk/gcc/tree-streamer-out.c:707 707 streamer_write_chain (ob, TYPE_FIELDS (expr), ref_p); $5 = <record_type 0x7ffff6a55498 array_descriptor01> $6 = <field_decl 0x7ffff6a531c8 data> Breakpoint 5, write_ts_type_non_common_tree_pointers (ob=0x2d15ce0, expr=<record_type 0x7ffff6a55738 array01_integer(kind=4)>, ref_p=false) at /tmp/trunk/gcc/tree-streamer-out.c:707 707 streamer_write_chain (ob, TYPE_FIELDS (expr), ref_p); $7 = <record_type 0x7ffff6a55738 array01_integer(kind=4)> $8 = <field_decl 0x7ffff6a531c8 data> and both record types are not variants of each other. Breakpoint 5, write_ts_type_non_common_tree_pointers (ob=0x2d15ce0, expr=<record_type 0x7ffff6a591f8 array01_a>, ref_p=false) at /tmp/trunk/gcc/tree-streamer-out.c:707 707 streamer_write_chain (ob, TYPE_FIELDS (expr), ref_p); $14 = <record_type 0x7ffff6a591f8 array01_a> $15 = <field_decl 0x7ffff6a531c8 data> It looks like this happens when doing build_distinct_type_copy () which simply copies TYPE_FIELDs. But I don't see how dwarf2out ever deals with this correctly... there's some weird unused push/pop_decl_scope () stuff around the call to gen_member_die (scope_die_for appearantly used it at some point). Without LTO these array descriptor types built by build_distinct_type_copy () never go the usual gen_member_die way but instead they go /* If this is an array type with hidden descriptor, handle it first. */ if (!TREE_ASM_WRITTEN (type) && lang_hooks.types.get_array_descr_info) { memset (&info, 0, sizeof (info)); if (lang_hooks.types.get_array_descr_info (type, &info)) { /* Fortran sometimes emits array types with no dimension. */ gcc_assert (info.ndimensions >= 0 && (info.ndimensions <= DWARF2OUT_ARRAY_DESCR_INFO_MAX_DIMEN)); gen_descr_array_type_die (type, &info, context_die); TREE_ASM_WRITTEN (type) = 1; return; which of course doesn't work when the FE is LTO.