MISRAC++2008-5-19-1
In this section:
Synopsis
(Advisory) Evaluation of constant unsigned integer expressions should not lead to wrap-around.
Enabled by default
No
Severity/Certainty
Medium/Medium

Full description
A constant unsigned integer expression overflows. This check is identical to EXPR-const-overflow, MISRAC2004-12.11, MISRAC2012-Rule-12.4, MISRAC++2023-8.20.1.
Coding standards
- CWE 190
Integer Overflow or Wraparound
- MISRA C:2004 12.11
(Advisory) Evaluation of constant unsigned integer expressions should not lead to wrap-around.
- MISRA C:2012 Rule-12.4
(Advisory) Evaluation of constant expressions should not lead to unsigned integer wrap-around
- MISRA C++ 2023 8.20.1
(Advisory) An unsigned arithmetic operation with constant operands should not wrap
Code examples
The following code example fails the check and will give a warning:
void example(void) {
(0xFFFFFFFF + 1u);
}
The following code example passes the check and will not give a warning about this issue:
void example(void) {
0x7FFFFFFF + 0;
}