On 5/19/20 9:34 AM, Ulrich Weigand wrote:
On Tue, Apr 28, 2020 at 02:13:02PM +0200, Jakub Jelinek wrote:
struct X { };
struct Y { int : 0; };
struct Z { int : 0; Y y; };
struct U : public X { X q; };
struct A { double a; };
struct B : public X { double a; };
struct C : public Y { double a; };
struct D : public Z { double a; };
struct E : public U { double a; };
This is only testing the [[no_unique_address]] attribute in the
most-derived class, but I believe the attribute also affects
members in the base class. Is this understanding correct?
Specifically, if we were to add two more tests to the above:
struct X2 { X x; };
struct X3 { [[no_unique_address]] X x; };
struct B2 : public X2 { double a; };
struct B3 : public X3 { double a; };
Then we should see that B2 does *not* count as single-element
struct, but B3 *does*. (That's also what GCC currently does.)
Just trying to get clarity here as I'm about to work on this
for clang ...
That sounds right to me, given that X3 counts as an empty class under
https://itanium-cxx-abi.github.io/cxx-abi/abi.html#definitions
empty class
A class with no non-static data members other than empty data members,
no unnamed bit-fields other than zero-width bit-fields, no virtual
functions, no virtual base classes, and no non-empty non-virtual proper
base classes.
Jason