MISRA C++:2008 Rule 9-6-3
Bit-fields shall not have enum type
Description
Rule Definition
Bit-fields shall not have enum type.
Rationale
Using bit fields requires that their underlying bit representations are not
implementation-defined. The ISO/IEC 14882:2003 does not explicitly define the signedness of
the underlying bit representation of enum
types. Because the sign of an
enum
type depends on the implementation, the exact number of bits that
is required to represent the values in the enum
is
implementation-defined.
To avoid code that behaves differently in different implementations and bugs that are
difficult to diagnose, do not use enum
types as bit fields.
Polyspace Implementation
Polyspace® reports a violation of this rule when you use enum
types as
bit fields.
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Classes |
Category: Required |
Version History
Introduced in R2013b