Tail padding, in sumary
Mark Mitchell
mark at codesourcery.com
Fri Aug 23 00:14:57 UTC 2002
There are several separate tail-padding issues that have been discussed
over the last few days and I want to make sure that we are all on the
same page about all of them as I am trying to revise the specification
accordingly.
HP, Intel folks please confirm statements below.
1) Should we reuse tail padding at all?
This was my original question; the specification was inconsistent.
The answer was decided as yes.
2) Should padding be at the bit-field level, or only at the byte level?
For example, given:
struct A { virtual void f(); int i : 3; };
struct B : public A { int j: 2; };
Is it OK to pack B::j into the same byte as A::i?
GCC does this (even though I think it a horrid idea due to the fact
that you can no longer create efficient copy constructors).
Neither Intel nor HP do this.
Therefore, I believe the spec should be changed to clarify that --
while the bytes following A::i are OK for use as padding -- the byte
containing A::i is not. (And, of course, GCC should be fixed.)
3) Should virtual bases be handled differently than non-virtual bases?
For example, given:
struct A { virtual void f(); char c1; };
struct B { B(); char c2; };
struct C : public A, public virtual B {};
Is B supposed to be packed into the tail-padding of A? In the case
that it is non-virtual, it is. However, in the virtual case GCC does
not reuse the tail-padding.
Probably, this is also a GCC bug, but I would like to know what HP
and Intel do.
HP, Intel?
--
Mark Mitchell mark at codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
More information about the cxx-abi-dev
mailing list