[Bug c++/87521] [C++][ABI] Tail padding not reused for non POD struct with defaulted/deleted special member function as per Itanium ABI on x86-64

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Nov 14 16:42:00 GMT 2018


--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The meaning of "user-declared" in C++03 is closer to "has a function body" than
the meaning in C++11, where it includes defaulted definitions.
A defaulted definition in C++11 is equivalent to an implicit (i.e. not
user-declared) definition in C++03. So I would argue that your type is a POD
for the purposes of layout, and GCC is correct.


struct Base {
    unsigned x;
    short y;
#if __cplusplus >= 201103L
    ~Base() = default;

struct Der : Base {
     short z;

int i[] = { sizeof(Base), sizeof(Der) };

I would argue that the #if block should not affect the ABI of this type, i.e.
it should be identical in C++03 and C++11, so it should be a "POD for the
purposes of layout". Otherwise adding explicitly-defaulted special members (to
conform to guidance like the Rule of Zero) causes ABI changes.

More information about the Gcc-bugs mailing list