Structure alignment changes when a constructor or destructor is added

Bruce Fraser kithril@gmail.com
Wed Dec 7 05:01:00 GMT 2011


Thank you.  This was helpful.  I'd been looking through the C++98 spec
but some parts of it are still difficult to mentally parse.  I had
found references elsewhere to the Itanium ABI, but not the actual
document so thanks for that link.  I understand now that it is not a
bug, it is certainly an oddity that you can generate better packing by
adding a constructor.  And it will make compatibility with the ABI of
our other platform impossible as most of the classes and structs have
constructors.

Bruce


On Wed, Dec 7, 2011 at 12:59 PM, Marc Glisse <marc.glisse@inria.fr> wrote:
> On Wed, 7 Dec 2011, Marc Glisse wrote:
>
>> And for std::tuple, this implies that:
>> struct A { long a; char b; };
>
>
> Argh, pasto... It was:
> struct A { long a; char b; A(double); };
>
>
>> sizeof(std::tuple<A,char>)==24
>> sizeof(std::tuple<char,A>)==24
>> because std::tuple has A as a member. If it had A as a base class, one of
>> those would be 16.
>>
>> The ABI is fun :-)
>
>
> --
> Marc Glisse



More information about the Gcc-help mailing list