Skip to main content

IAR Embedded Workbench for RX 5.20

MISRAC++2008-6-5-1_b (C++ only)

In this section:
Synopsis

(Required) A for loop shall contain a single loop-counter which shall not have floating type.

Enabled by default

Yes

Severity/Certainty

Low/Medium

lowmedium.png
Full description

Multiple variables are being used to control 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;
  for (int i = 0; i < j; i = j++)
  {}
}

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

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