https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86763
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |NEW CC| |jason at gcc dot gnu.org, | |nathan at gcc dot gnu.org, | |rguenth at gcc dot gnu.org Component|middle-end |c++ --- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> --- So the question is why T doesn't get TYPE_TYPELESS_STORAGE set even though we propagate that flag from children upwards in place_field. That's what is missing here and why things go wrong. Ah, so we go build_base_field (rli=0x2ea1780, binfo=0x7ffff6a2f120, offsets=0x2ea2280, next_field=0x7ffff6a285c8) at /space/rguenther/src/svn/gcc-8-branch/gcc/cp/class.c:4244 4244 tree t = rli->t; (gdb) p basetype->type_common.typeless_storage $30 = 1 OK 4262 decl = build_base_field_1 (t, basetype, next_field); (gdb) p decl->typed.type->type_common.typeless_storage $31 = 0 looks like the as-base type doesn't inherit this flag. If I fix that up here where it matters rather than tracking down the gazillion places the C++ FE seems to set CLASSTYPE_AS_BASE and where I'm unsure at that time layout is finished the bug is fixed: Index: gcc/cp/class.c =================================================================== --- gcc/cp/class.c (revision 263209) +++ gcc/cp/class.c (working copy) @@ -4202,6 +4202,8 @@ build_base_field_1 (tree t, tree basetyp { /* Create the FIELD_DECL. */ gcc_assert (CLASSTYPE_AS_BASE (basetype)); + TYPE_TYPELESS_STORAGE (CLASSTYPE_AS_BASE (basetype)) + = TYPE_TYPELESS_STORAGE (basetype); tree decl = build_decl (input_location, FIELD_DECL, NULL_TREE, CLASSTYPE_AS_BASE (basetype)); DECL_ARTIFICIAL (decl) = 1; C++ folks?