...
In this noncompliant code example, initializer expressions for all enumeration constants in enum attrib_mask are unsigned integers. However, the C Standard says (section 6.1.3.3 [ISO/IEC 9899:1990]) that enumeration constants have type int. The bitwise OR is applied to signed integers which is implementation-defined behavior.
| Code Block | ||||
|---|---|---|---|---|
| ||||
enum attrib_mask
{
POINT_BIT = 0x02U,
LINE_BIT = 0x04U
};
unsigned int mask = (POINT_BIT | LINE_BIT);
|
...