Help with bit-field semantics in C and C++

Gabriel Dos Reis gdr@integrable-solutions.net
Tue Aug 24 23:09:00 GMT 2004


Mike Stump <mrs@apple.com> writes:

[...]

| which if you squint, you can see it more closely matches my example...
| 
| > | e = 7;
| 
| Ok, I blew that one...  I was thinking of a slightly different test
| case.  One that made full use of the full range of the underlying type
| in a portable program.

As repeatedly demonstrated, only use of the bit-sized full range is
covered. Not the whole underlying integer type.

| T<sizeof (e)> x = 7;
| memcpy ((char *)&e, (char *)&x, sizeof (e));
| 
| The issue remains the same...  Could be good DR material...
| 
| > Values of type bool are either true or false.42)
| 
| Yeah, and I was thinking of:
| 
|    42) Using a bool value in ways described by this  International  Stan-
|    dard as ``undefined,'' such as by examining the value of an uninitial-
|    ized automatic variable, might cause it to behave  as  if  is  neither
|    true nor false.

That is a (non-normative) note to remind that a trap representation is
still permitted for bools, not a note that would contractid the very
rule (of which this footnote is appended) that  any value of bool type
is either false or true. 



More information about the Gcc mailing list