This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: typeof and bitfields
- From: Paul Schlie <schlie at comcast dot net>
- To: <dave dot korn at artimi dot com>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Fri, 14 Jan 2005 11:44:54 -0500
- Subject: RE: typeof and bitfields
> 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, 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?
I'd say -1 or 0, clearly if it's presumed min-int == (-max-int - 1) holds.
To be somewhat more philosophical, wonder if in hind-sight, bool true may
have been better defined as being -1 vs. 1, thereby also creating a stronger
analogy between logical and bitwise operations extended to arbitrary sized
integers/bit-fields.
- (x & true) :: per bit &
- (x && true) :: aggregated &
(although likely irrelevant now)