T
Tim Rentsch
Ben Bacarisse said:Keith Thompson said:Ben Bacarisse said:Keith Thompson <[email protected]> writes: [...]It's not clear (to me, anyway) what the width of _Bool is supposed to
be. It seems to me that the Standard doesn't preclude either of the
following (assume CHAR_BIT==8 and sizeof(_Bool)==1):
_Bool has 1 value bit and 7 padding bits and can only represent
the values 0 and 1; its width is 1.
_Bool has 8 value bits and can represent values from 0 to
255 inclusive (but storing a value other than 0 or 1 requires
tricks); its width is 8.
I think both are permitted along with all points in between (i.e. any
width from 1 to CHAR_BIT seems to me to be permitted). I can't find any
text that imposes any tighter constraints on the implementation.
Are widths exceeding CHAR_BIT forbidden? I know that _Bool is required
to have a lower rank than any other standard integer type, but I don't
think that implies it can't have a wider range than unsigned char
(though it could cause some interesting effects if it does).
I think you are right, and I'd come to the same conclusion while writing
another post but forgot it by the time I replied here! I see no reason
why _Bool can't be wider that unsigned char.
6.2.5p8. _Bool is an unsigned type, so its width can't
be larger than the width of unsigned char. (The range of
values determines the width, per 6.2.6.2p1 and 6.2.6.2p6.)