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

Richard Smith richardsmith at google.com
Thu Feb 5 00:26:41 UTC 2015


Change the final paragraph of 2.4/II/3 as follows:

"""
Once offset(D) has been chosen, update sizeof(C) to max (sizeof(C),
offset(D)+sizeof(D))
<ins>, and align(C) to max (align(C), nvalign(D))</ins>.
<del>Note that nvalign(D) is 1, so no update of align(C) is needed.</del>
S<del>imilarly, s</del>ince D is an empty base class, no update of dsize(C)
is needed.
"""

On 4 February 2015 at 16:11, John McCall <rjmccall at apple.com> wrote:

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


More information about the cxx-abi-dev mailing list