MISRAC++2023-9.5.1_c
In this section:
Synopsis
(Advisory) Legacy for statements should be simple
Enabled by default
No
Severity/Certainty
Low/Low

Full description
The increment or decrement of the loop variable must be simple (++, --, +=, -=) and constant This check is identical to MISRAC++2008-6-5-4.
Coding standards
- MISRA C++ 2008 6-5-4
(Required) The loop-counter shall be modified by one of: --, ++, -=n, or +=n; where n remains constant for the duration of the loop.
Code examples
The following code example fails the check and will give a warning:
void example(void)
{
int i;
for(i = 0; i != 10; i= i * i) {}
}
The following code example passes the check and will not give a warning about this issue:
void example(void)
{
bool b;
for(int i = 0; i != 10 || b; i-=2) {}
}