This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[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
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 14 Nov 2018 16:42:32 +0000
- Subject: [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
- Auto-submitted: auto-generated
- References: <bug-87521-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87521
--- 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.
Consider:
struct Base {
unsigned x;
short y;
#if __cplusplus >= 201103L
~Base() = default;
#endif
};
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.