This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: typeof and bitfields
- From: Andrew Haley <aph at redhat dot com>
- To: "Dave Korn" <dave dot korn at artimi dot com>
- Cc: "'Ian Lance Taylor'" <ian at airs dot com>, "'Neil Booth'" <neil at daikokuya dot co dot uk>, "'Matt Austern'" <austern at apple dot com>, "'Gabriel Dos Reis'" <gdr at integrable-solutions dot net>, <gcc at gcc dot gnu dot org>, "'Andrew Pinski'" <pinskia at physics dot uc dot edu>
- Date: Fri, 14 Jan 2005 16:10:04 +0000
- Subject: RE: typeof and bitfields
- References: <m3sm54hfvu.fsf@gossamer.airs.com><NUTMEGZfv4eqfxrCXIj00001066@NUTMEG.CAM.ARTIMI.COM>
Dave Korn writes:
>
> While we're on the subject, I've always been curious what on earth the meaning
> of
>
> struct foo {
> int bar : 1;
> };
>
> could possibly mean. What are the range of values in a 1-bit
> signed int? Is that 1 bit the sign bit or the value field? Can
> bar hold the values 0 and 1, or 0 and -1, or some other set? (+1
> and -1,
That one.
> maybe, or perhaps the only two values it can hold are +0
> and -0?) In a one bit field, the twos-complement operation
> degenerates into the identity - how can the concept of signed
> arithmetic retain any coherency in this case?
It's the ring of integers modulo 2. In that ring,
-1 == 1 (mod 2)
^ is congruent to
I don't think there's anything particularly weird about it from a
number theory point of view.
Andrew.