Skip to main content

IAR Embedded Workbench for Arm 9.70.x

MISRAC2012-Rule-14.1_a

In this section:
Synopsis

(Required) A loop counter shall not have essentially floating type.

Enabled by default

Yes

Severity/Certainty

Low/Medium

lowmedium.png
Full description

A loop counter were found having floating type. This check is identical to MISRAC++2008-6-5-1_a, CERT-FLP30-C_a.

Coding standards
CERT FLP30-C

Do not use floating point variables as loop counters

MISRA C:2012 Rule-14.1

(Required) A loop counter shall not have essentially floating type

MISRA C++ 2008 6-5-1

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

Code examples

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


int main() {
   for (float i = 0.0; i < 10.0; ++i)
   {
   }
   return 0;
}

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


int main() {
   for (int i = 0; i < 10; ++i)
   {
   }
   return 0;
}