Skip to main content

IAR Embedded Workbench for Arm 9.70.x

MISRAC++2008-5-2-10

In this section:
Synopsis

(Advisory) The increment (++) and decrement (--) operators should not be mixed with other operators in an expression.

Enabled by default

No

Severity/Certainty

Low/Medium

lowmedium.png
Full description

The increment (++) and decrement (--) operators are being used mixed with other operators in an expression. This check is identical to MISRAC2004-12.13, MISRAC2012-Rule-13.3.

Coding standards
MISRA C:2004 12.13

(Advisory) The increment (++) and decrement (--) operators should not be mixed with other operators in an expression.

MISRA C:2012 Rule-13.3

(Advisory) A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator

Code examples

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

void example(char *src, char *dst) {
	while ((*src++ = *dst++));
}

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

void example(char *src, char *dst) {
	while (*src) {
		*dst = *src;
		src++;
		dst++;
	}
}