This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] What should be the semantics of a zero-bit bit-field withpragma pack?
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Steven Bosscher <stevenb at suse dot de>
- Cc: gcc at gcc dot gnu dot org, jason at redhat dot com, marcus at jet dot franken dot de, joseph at codesourcery dot com
- Date: Mon, 07 Nov 2005 11:53:10 -0800
- Subject: Re: [RFC] What should be the semantics of a zero-bit bit-field withpragma pack?
- References: <200511072034.18179.stevenb@suse.de>
Steven Bosscher wrote:
> Of course, the semantics of "int : 0" are not defined by C99 for packed
> structs. As far as I can tell, extend.texi doesn't discuss this case,
> so we need to come up with something that makes sense.
The semantics of zero-width bitfields (outside of packed structures) are
part of the ABI for each system. They very somewhat from
system-to-system, but, in general, they are interpreted as alignment
directives.
> We discussed this briefly on IRC. We have only two options AFAICT:
> 1) ignore the ": 0" field completely. This is what we seem to do
> since Jason's patch was commited.
> 2) when we see :0 align to the next unit, which seems to be the
> behavior of GCC pre-3.4.
>
> Jason suggested that it looks like they want it to mean "align the
> next field despite pragma pack". So that is option (2),
Yes, I think we should do option (2). There's otherwise no point at all
in putting a zero-width bitfield into a packed structure; it seems
better to assume the user had a purpose in having the zero-width bitfield.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304