https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120012

            Bug ID: 120012
           Summary: [12/13/14/15/16 Regression] P1008R1 causes tail
                    padding reuse in C++20 mode
           Product: gcc
           Version: 15.1.0
            Status: UNCONFIRMED
          Keywords: ABI
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

struct A
{
   A(const A&) = default;
   A(A&&) = default;
   A& operator=(A&&) = default;
   unsigned int a;
   unsigned char b;
};
struct B: A
{
   unsigned char c;
};

static_assert(sizeof(A) == (2 * sizeof(unsigned int)));

//static_assert(sizeof(B) == (2 * sizeof(unsigned int)));
static_assert(sizeof(B) == (3 * sizeof(unsigned int)));

This final static_assert passes with -std=gnu++17 but fails with -std=gnu++20,
since r9-2103-g686dca7612a8ab

commit 686dca7612a8ab5ebebad2fc13bd9ea7793a7e40 [r9-2103-g686dca7612a8ab]
Author:     Jakub Jelinek
AuthorDate: Tue Jul 31 15:19:26 2018

    P1008R1 - prohibit aggregates with user-declared constructors

            P1008R1 - prohibit aggregates with user-declared constructors
            * class.c (check_bases_and_members): For C++2a set
            CLASSTYPE_NON_AGGREGATE based on TYPE_HAS_USER_CONSTRUCTOR rather
than
            type_has_user_provided_or_explicit_constructor.


The https://wg21.link/P1008R1 change makes the type a non-aggregate, but we
apparently also treat it as no longer pod-for-layout and so start to use its
tail padding for the derived class.

Reply via email to