MISRAC2012-Rule-10.1_R6
In this section:
Synopsis
(Required) Operands shall not be of an inappropriate essential type.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
Shift and bitwise operations were found performed on operands of essentially signed type.
Coding standards
- MISRA C:2012 Rule-10.1
(Required) Operands shall not be of an inappropriate essential type
Code examples
The following code example fails the check and will give a warning:
void example(void) {
int x = -(1U);
x ^ 1;
x & 0x7F;
((unsigned int)x) & 0x7F;
}
The following code example passes the check and will not give a warning about this issue:
void example(void) {
int x = -1;
((unsigned int)x) ^ 1U;
2U ^ 1U;
((unsigned int)x) & 0x7FU;
((unsigned int)x) & 0x7FU;
}