[cxx-abi-dev] Layout of overaligned empty base classes

John McCall rjmccall at apple.com
Thu Feb 5 00:11:03 UTC 2015


> On Apr 24, 2014, at 2:52 PM, Richard Smith <richardsmith at google.com> wrote:
> 2.4/II/3 says:
> 
> "If D is an empty proper base class: [...potentially misalign the D base class...] Note that nvalign(D) is 1, so no update of align(C) is needed."
> 
> This is not true.
> 
> struct A {};
> struct B : A { char c; };
> struct alignas(4) D : A {};
> struct C : B, D {};
> 
> This puts a D object at offset 1 within C, and gives C nvalign of 1, which is obviously not right. Fortunately, GCC, Clang, and EDG all deviate from the ABI and instead do the natural thing here (put it at offset zero if you can, and otherwise allocate it like any other subobject). Looks like the wording only needs a little massaging here to say the right thing.

Catching up on my queue, and I found this very old email.  Would you mind proposing an exact wording change?

John.


More information about the cxx-abi-dev mailing list