Skip to main content

IAR Embedded Workbench for Arm 9.70.x

MISRAC2012-Rule-12.4

In this section:
Synopsis

(Advisory) Evaluation of constant expressions should not lead to unsigned integer wrap-around

Enabled by default

No

Severity/Certainty

Low/Medium

lowmedium.png
Full description

Evaluation of constant expressions lead to unsigned integer wraparound. This check is identical to EXPR-const-overflow, MISRAC++2008-5-19-1, MISRAC2004-12.11, MISRAC++2023-8.20.1.

Coding standards
MISRA C:2004 12.11

(Advisory) Evaluation of constant unsigned integer expressions should not lead to wrap-around.

MISRA C++ 2008 5-19-1

(Advisory) Evaluation of constant unsigned integer expressions should not lead to 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;
}