Skip to main content

IAR Embedded Workbench for RL78 5.20

MISRAC++2023-9.5.1_d

In this section:
Synopsis

(Advisory) Legacy for statements should be simple

Enabled by default

No

Severity/Certainty

Low/Medium

lowmedium.png
Full description

For loop controlling variables may not be modified or aliased to a non const pointer or reference. This check assumes an otherwise well formed for statement according to 9.5.1.

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() {
  for ( int i = 0; i < 10; ++i ) 
  {
    i += 1; // Non-compliant
  }  
}

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

void example() {
  for ( int i = 0; i < 10; i += 2 ) 
  {
     ; // Compliant
  }  
}