[cxx-abi-dev] question on the virtual base offset

Mark Mitchell mark at codesourcery.com
Tue Nov 9 06:55:36 UTC 2004


Kerch Holt wrote:

The question raised here was how an unnamed bitfield should be handled 
in a non-POD.  (In a POD, the C++ ABI is clear -- follow the rules of 
the C ABI.)

> Since E only contains an "unnamed bitfield" which is not even considered
> a member (see 9.6 P2) I think the nvalign(E) should be 1.

Wow, I didn't realize an unnamed bitfield was not a member.

> Does this need extra wording in the ABI to deal with the special case
> of unnamed bitfields? Perhaps alter 2.4 II 1. to say:
>     If D is not an unnamed bitfield
>         update align(C) to max(align(C),align(T))

I think the right thing to do is to handle unnamed bitfields as they 
would be handled in the underlying C ABI.  In some C ABIs, that results 
in an update to the alignment; in other C ABIs it does not.

2.4 II 1 is already trying to make the identifier optional through the 
use of "[b]" in the declarator.  I suggest making several edits to this 
section to try to clarify these points:

1) Revise the first paragraph of 2.4 II to say:

"then the non-static data members (including unnamed bitfields, although 
they are not members in ISO C++) in declaration order"

2) Replace the introductory clause in 2.4.II.1 with:

"If D is a (possibly unnamed) bitfield whose declared type is T and 
whose declared width is n bits,"

3) Update 2.4.II.1.a to read:

"If sizeof (T) * 8 >= n, the bitfield is allocated as required by the 
underlying C psABI, subject to the constraint that a bitfield is never 
placed in the tail padding of a base class of C.

For example, on Itanium, the bitfield is placed in the next available n 
bits, subject to the constraint that it does not cross an alignment 
boundary for type T.  If dsize(C) > 0, and the byte at offset dsize(C) - 
1 is partially filled by a bitfield, and that bitfield is also a data 
member declared in C (but not in one of C's proper base classes), the 
next available bits are the unfilled bits at offset dsize(C) - 1. 
Otherwise, the next available bits are at offset dsize(C).  Update 
align(C) to max (align(C), align(T))."

I will make these clarifications in a few days, if there are no objections.

Thanks,

-- 
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery.com



More information about the cxx-abi-dev mailing list