2019-08-30 Jakub Jelinek Backported from mainline 2018-11-27 Jakub Jelinek PR c++/88181 * class.c (fixup_attribute_variants): Also propagate TYPE_PACKED to variants. * g++.dg/debug/pr88181.C: New test. --- gcc/cp/class.c (revision 267688) +++ gcc/cp/class.c (revision 267689) @@ -1957,6 +1957,7 @@ fixup_attribute_variants (tree t) unsigned align = TYPE_ALIGN (t); bool user_align = TYPE_USER_ALIGN (t); bool may_alias = lookup_attribute ("may_alias", attrs); + bool packed = TYPE_PACKED (t); if (may_alias) fixup_may_alias (t); @@ -1974,6 +1975,7 @@ fixup_attribute_variants (tree t) else TYPE_USER_ALIGN (variants) = user_align; SET_TYPE_ALIGN (variants, valign); + TYPE_PACKED (variants) = packed; if (may_alias) fixup_may_alias (variants); } --- gcc/testsuite/g++.dg/debug/pr88181.C (nonexistent) +++ gcc/testsuite/g++.dg/debug/pr88181.C (revision 267689) @@ -0,0 +1,29 @@ +// PR c++/88181 +// { dg-do compile } +// { dg-options "-fpack-struct -g -std=c++11" } + +template struct A { typedef T B; }; +template class C; +template struct D { constexpr D (e) {} }; +template struct E; +template +struct E : E<1, U...>, D { + constexpr E (T x, U... y) : E<1, U...>(y...), D(x) {} +}; +template struct E : D { + constexpr E (T x) : D(x) {} +}; +template struct C : E<0, T, U> { + constexpr C (T x, U y) : E<0, T, U>(x, y) {} + void operator= (typename A::B); +}; +struct F {}; +struct G {}; + +int +main () +{ + F f; + G g; + constexpr C c(f, g); +}