Actions

icon Post
text/html Subscribe
text/html Unsubscribe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cxx-abi-dev] How to layout the class (with bitfield members) in the inheritance hierarchy on GCC 3.3


  • To: Yan Shi <yanshi@xxxxxxxxxx>
  • Subject: Re: [cxx-abi-dev] How to layout the class (with bitfield members) in the inheritance hierarchy on GCC 3.3
  • From: Mark Mitchell <mark@xxxxxxxxxxxxxxxx>
  • Date: Tue, 01 Jun 2004 18:12:01 -0700

Yan Shi wrote:




Hi,

According to C++ ABI 2.4 Non-POD Class Types defintion:
"Allocation of Members Other Than Virtual Bases
For each data component D (first the primary base of C, if any, then the
non-primary, non-virtual direct base classes in declaration order, then the
non-static data members in declaration order), allocate as follows:

For the following test cases, the bitfield members (b0, b1, b2, b3, b4),
should all be allocated together in 4 bytes, therefore the total size of
struct B4 (test2.C) should be 8 bytes and the alignment of struct B4 is 4
bytes.

However, I tried both test cases with GCC 3.3 on SLES9 Linux, the size of
struct B4 (test2.C) is 12 bytes, while the alignment of struct B4 is 4
bytes on 32-bit mode, which does not agree with the ABI definition.  Could
some one please explain what the rules/algorithm for such behavior in GCC
3.3?

G++ 3.3 has known bugs in this area of the ABI. We believe that those bugs have been corrected in GCC 3.4.0. You might also try "-fabi-version=0" with G++ 3.3, which eliminates some of the bugs. (Some of the bugs were preservedin 3.3 for backwards compatibility with earlier versions of G++.)

--
Mark Mitchell
CodeSourcery, LLC
mark@xxxxxxxxxxxxxxxx