------- Comment #29 from mark at codesourcery dot com  2006-01-18 23:00 -------
Subject: Re:  [3.4/4.0/4.1/4.2 Regression] bitfield
 layout change (regression?)

I think that we should do as follows.

Preserve the original value of maximum_field_alignment when doing
#pragma pack.  Then, for zero-width bitfields, we should align to the
minimum of the original maximum_field_alignment and the otherwise
natural alignment.

The difference between this and the last proposed patch is that I don't
think we should entirely ignore maximum_field_alignment for zero-width
bitfields; if "long long" as a field will only have (say) 2-byte
alignment on some embedded target where structure-packing is the
default, then a "long long : 0;" bitfield should only force 4-byte
alignment.

However, that's an abstract argument; I'm not actually sure what
existing practice was with older versions of GCC.

Again, in the abstract, I think the example in Comment #12 ought to have
size 8 on both IA32 and AMD64 architectures.  I can't see any good
justification for size 12, with a PCC_BITFIELD_TYPES_MATTER ABI.  And, I
think that the size of the structure with #pragma pack(1) ought to be
the same as with __attribute__((packed)).

So, my concern with the patch in Comment #12 is that it would ignore the
pre-set maximum_field_alignment on targets with default structure
packing; other than that, I think it looks fine.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22275

Reply via email to