MISRAC2012-Rule-10.1_R7
In this section:
Synopsis
(Required) Operands shall not be of an inappropriate essential type. The right-hand operand of a shift operator is not of essentially unsigned type, meaning that undefined behavior might result from a negative shift.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
The right-hand operand of a shift operator is not of essentially unsigned 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 a;
unsigned int b;
b << a;
}
The following code example passes the check and will not give a warning about this issue:
void example(void) {
unsigned int a;
unsigned int b;
b << a;
}