Skip to main content

IAR Embedded Workbench for RH850 3.20.x

MISRAC++2008-6-5-6

In this section:
Synopsis

(Required) A loop-control-variable other than the loop-counter which is modified in statement shall have type bool.

Enabled by default

Yes

Severity/Certainty

Low/Low

lowlow.png
Full description

A non-boolean variable was detected that is modified in the loop and used as loop condition.

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 example(void)
{
  int j;
  for (int i = 0; i < 10 || j > 5; ++i)
  {
    j = i;
  }
}

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

void example(void)
{
  bool found = false;
  for (int i = 0; i < 10 || found; ++i)
  {
    found = (i + 1) % 9;
  }
}