Skip to main content

IAR Embedded Workbench for RL78 5.20

MISRAC++2008-6-5-4

In this section:
Synopsis

(Required) The loop-counter shall be modified by one of: --, ++, -=n, or +=n; where n remains constant for the duration of the loop.

Enabled by default

Yes

Severity/Certainty

Low/Low

lowlow.png
Full description

A potentially inconsistent loop counter modification was found. This check is identical to MISRAC++2023-9, 5.1, _c.

Coding standards
MISRA C++ 2023 9.5.1

(Advisory) Legacy for statements should be simple

Code examples

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

void example(void)
{
  int i;
  for(i = 0; i != 10; i= i * i) {}
}

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

void example(void)
{
  bool b;
  for(int i = 0; i != 10 || b; i-=2) {}
}