...
It is implementation-defined whether the specifier int
designates the same type as signed int
or the same type as unsigned int
for bit-fields. According to the C standard Standard [ISO/IEC 9899:2011], C integer promotions also require that "if an int
can represent all values of the original type (as restricted by the width, for a bit-field), the value is converted to an int
; otherwise, it is converted to an unsigned int
."
...
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
Include Page | LDRA_V | LDRA_V | 73 S | Fully implemented||||||
Compass/ROSE |
|
|
| ||||||
| bitftype | Fully implemented | |||||||
| 73 S | Fully implemented | |||||||
PRQA QA-C |
| 0634 (I) | Fully implemented |
...
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
...
INT12-CPP. Do not make assumptions about the type of a plain int bit-field when used in an expression | |
---|---|
ISO/IEC TR 24772 | Bit representations [STR] |
MISRA-C | Rule 12.7 (required): Bitwise operators shall not be applied to operands whose underlying type is signed |
Bibliography
...
] | Section 6.3.1.1, "Boolean, |
---|
...
Characters, and |
---|
...
Integers" |
---|
ISO/IEC TR 24772 "STR Bit representations"
MISRA Rule 12.7
...
...