[cxx-abi] Re: [cxx-abi-dev] Tail padding, in sumary

Mark Mitchell mark at codesourcery.com
Mon Aug 26 16:30:05 UTC 2002



--On Monday, August 26, 2002 08:08:42 AM -0700 "Nelson, Clark" 
<clark.nelson at intel.com> wrote:

> it, so I'll add
>> Although that would be an excellent solution, there'd be some
>> awkwardness
>> explaining that C has a different layout to B
>> 	struct B : A { int j : 2;};
>> At the momement, they should have the same layout.
>
> So in a case like this:
>
> struct X { int x: 1; };
> struct Y { struct X x; int y: 1; };
>
> I think it would be far more awkward to explain that you can't copy the x
> member using memcpy without running the risk of modifying y. Note that
> this case is expressible in C. Surely the base (C) ABI doesn't have x and
> y overlapping at the byte level.

In the case you give, X is a POD.  So, we cannot reuse the padding.

If X is a non-POD, then the C++ standard no longer guarantees that you
can use memcpy under any circumstances, including these.

> For what it's worth, I never read the ABI as saying that this should be
> the case. Could someone please point out the words I'm missing?

Nathan, I agree with Clark; the last portion of 2.4.II.2 disallows this;

  If D is a data member, update dsize(C) to offset(D)+sizeof(D)

The fact that dsize is incremented by the full size of D means that there
is no padding available.

-- 
Mark Mitchell                mark at codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com



More information about the cxx-abi-dev mailing list