MISRAC++2008-6-5-1_a
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

Full description
A loop counter were found having floating type. This check is identical to MISRAC2012-Rule-14.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
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;
}