Skip to main content

IAR Embedded Workbench for RL78 5.20

MISRAC2004-13.4

In this section:
Synopsis

(Required) The controlling expression of a for statement shall not contain any objects of floating type.

Enabled by default

Yes

Severity/Certainty

Low/Medium

lowmedium.png
Full description

Floating-point values were found in the controlling expression of a for statement.

Coding standards
MISRA C:2004 13.4

(Required) The controlling expression of a for statement shall not contain any objects of floating type.

Code examples

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

void example(int input, float f) {
  int i;
  for (i = 0; i < input && f < 0.1f; ++i) {
  }
}

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

void example(int input, float f) {
  int i;
  int f_condition = f < 0.1f;
  for (i = 0; i < input && f_condition; ++i) {
    f_condition = f < 0.1f;
  }
}