Help with bit-field semantics in C and C++
Gabriel Dos Reis
gdr@integrable-solutions.net
Tue Aug 24 23:27:00 GMT 2004
Mike Stump <mrs@apple.com> writes:
| On Tuesday, August 24, 2004, at 02:42 PM, David Carlton wrote:
| > Just to clarify: I agree that, it's okay if, on one run of the
| > program, the program behaves as if it's 0 and on another run of the
| > program, the program behaves as if it's 1, or other similar
| > pathologies. But I don't see how the standard allows the program to
| > behave as if the value is neither 0 nor 1.
|
| (E)n, where n is an int with value, say of 7, is permitted by the
| standard to take on the value 7. This is because the text of the
| standard says the value is unspecified. 7 is a unspecified value,
| honest.
In the example,
enum E { zero = 0x00, one = 0x01 };
for which the minimum bits of representation is 1, 7 is not an
enumeration value. A fortiori, it is not a honest unspecified
enumeration value.
-- Gaby
More information about the Gcc
mailing list