Skip to main content

IAR Embedded Workbench for RX 5.20

MISRAC++2008-6-5-5

In this section:
Synopsis

(Required) A loop-control-variable other than the loop-counter shall not be modified within condition or expression.

Enabled by default

Yes

Severity/Certainty

Low/Medium

lowmedium.png
Full description

A non-loop-counter variable was found that is assigned in the condition or expression part of a for loop.

Coding standards

This check does not correspond to any coding standard rules.

Code examples

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

void func()
{
  int j;
  int x;
  for (int i = 0; i < 10; j++ )
  {
    i++;
  }
}

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

void func()
{
  int j;
  int x;
  for (int i = 0; i < 10; i++ )
  {
    j++;
  }
}