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

Richard Smith richardsmith at google.com
Thu Apr 24 21:52:23 UTC 2014


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20140424/265b9698/attachment.html>


More information about the cxx-abi-dev mailing list