...
The internal representations of bit-field structures have several properties (such as internal padding) that are implementation-defined. Additionally, bit-field structures have several implementation-defined constraints:
...
Bit fields can be used to allow flags or other integer values with small ranges to be packed together to save storage space. Bit fields can improve the storage efficiency of structures. Compilers typically allocate consecutive bit-field structure members into the same int
-sized storage, as long as they fit completely into that storage unit. However, the order of allocation within a storage unit is implementation-defined. Some implementations are right-to-left: the first member occupies the low-order position of the storage unit. Others are left-to-right: the first member occupies the high-order position of the storage unit. Calculations that depend on the order of bits within a storage unit may produce different results on different implementations.
...
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
Compass/ROSE |
|
| Can detect violations of this recommendation. Specifically, it reports violations if
| ||||||
| 94 S | Fully implemented. | |||||||
PRQA QA-C |
| 0310 | Partially implemented |
Related Vulnerabilities
...
ISO/IEC TR 17961 (Draft) Accessing an object through a pointer to an incompatible type [ptrcomp]
ISO/IEC TR 24772 "STR Bit representations"
MISRA Rule 3.5
Bibliography
[Plum 1985] Rule 6-5
...