Help with bit-field semantics in C and C++
Gabriel Dos Reis
gdr@integrable-solutions.net
Fri Aug 27 22:49:00 GMT 2004
"Steven L. Zook" <SLZook@Qualstar.com> writes:
| Ok, it sounds like I wasn't tracking the discussion quite right
| (which is what I was trying to ascertain). By "enumeration value" it
| sounds like what you mean is a numerical representation that fits in
| the minimum bit width of the type (in my example case 4 bits in
| width and so any of 16 values would qualify, thus a masking
| operation can always bring any integer value into range).
That is what the Standard C++ says, 7.2/6:
For an enumeration where emin is the smallest enumerator and emax is
the largest, the values of the enumeration are the values of the
underlying type in the range bmin to bmax, where bmin and bmax are,
respectively, the smallest and largest values of the smallest
bit-field that can store emin and emax.81) It is possible to define
an enumeration that has values not defined by any of its
enumerators.
-- Gaby
More information about the Gcc
mailing list