This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/22275] [3.4/4.0/4.1/4.2 Regression] bitfield layout change (regression?)
- From: "mark at codesourcery dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Jan 2006 23:00:41 -0000
- Subject: [Bug middle-end/22275] [3.4/4.0/4.1/4.2 Regression] bitfield layout change (regression?)
- References: <bug-22275-3760@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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