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

--- Comment #1 from Barry Revzin <barry.revzin at gmail dot com> ---
Basically, in C++17, Sub looks like this:

struct Sub17 : Empty {
    aligned_membuf<Empty> storage;
    unsigned char index;
};

But in C++20 it turns into:

struct Sub20 : Empty {
    union { Empty storage; };
    unsigned char index;
};

sizeof(Sub17) == 2 because of the empty base optimization, but sizeof(Sub20) ==
3 because now the language understands that storage is an Empty and thus needs
a distinct address from the Empty base class.

Reply via email to