If a value of integral type (other than
bool) is stored
into a bit-field of width
N and the value would be representable
in a hypothetical signed or unsigned integer type
with width
N and the same signedness as the bit-field's type,
the original value and the value of the bit-field compare equal
. If the value
true or
false is stored into a bit-field of
type
bool of any size (including a one bit bit-field), the
original
bool value and the value of the bit-field compare
equal
. If a value of an enumeration type is stored into a bit-field of the
same type and the width is large
enough to hold all the values of that enumeration type (
[dcl.enum]),
the original value and the value of the bit-field compare equal
. [
Example 1:
enum BOOL { FALSE=0, TRUE=1 };
struct A {
BOOL b:1;
};
A a;
void f() {
a.b = TRUE;
if (a.b == TRUE)
{ }
}
—
end example]