Skip to main content

IAR Embedded Workbench for RH850 3.20.x

MISRAC++2008-2-13-3

In this section:
Synopsis

(Required) A "U" suffix shall be applied to all octal or hexadecimal integer literals of unsigned type.

Enabled by default

Yes

Severity/Certainty

Low/Low

lowlow.png
Full description

There are unsigned integer constants without a U suffix. This check is identical to MISRAC2004-10.6, MISRAC2012-Rule-7.2, MISRAC++2023-5.13.4.

Coding standards
MISRA C:2004 10.6

(Required) A U suffix shall be applied to all constants of unsigned type.

MISRA C:2012 Rule-7.2

(Required) A "u" or "U" suffix shall be applied to all integer constants that are represented in an unsigned type

MISRA C++ 2023 5.13.4

(Required) Unsigned integer literals shall be appropriately suffixed

Code examples

The following code example fails the check and will give a warning:

void example(void) {
	// 2147483648 -- does not fit in 31bits
	unsigned int x = 0x80000000;
}

The following code example passes the check and will not give a warning about this issue:

void example(void) {
	unsigned int x = 0x80000000u;
}