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

            Bug ID: 87521
           Summary: [C++][ABI] Tail padding not reused for non POD struct
                    with defaulted/deleted special member function as per
                    Itanium ABI on x86-64
           Product: gcc
           Version: 8.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bruno.bugs.contact at gmail dot com
  Target Milestone: ---

Consider (https://godbolt.org/z/fSnWB1) (On x86-64)

struct Base {
    unsigned x;
    short y;
    ~Base() = default; // same with = delete
};

struct Der : Base {
     short z;
};

With GCC sizeof(Der) == 12 instead of the expected 8.
The problem here (if I am reading the spec correctly)
is that the defaulted or deleted destructor qualifies
as user-declared, which makes Base a non-POD-struct
*as per C++03* (but not as per C++11),
which means that according to the Itanium ABI the tail padding
of Base should be reused. The same problem exists with the other
special member functions and with = delete instead.

This is not a recent problem and goes back to at least GCC 4.4.7,
which makes me think that this is maybe intended, but clang reuse
the tail padding in these cases which make this an annoying ABI
incompatibility. As an additional data point ICC seems to agree
with GCC on this.

Reply via email to