AutosarC++17_10-M6.5.2¶
If loop-counter is not modified by – or ++, then, within condition, the loop-counter shall only be used as an operand to <=, <, > or >=
Required inputs: IR
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
Rationale
When the loop-counter is modified using an operator other than -- or ++, then == and != shall not be used, as loop termination may not occur, which may be inconsistent with developer expectations.
Example
for ( i = 1; i != 10; i += 2 ) // Non-compliant
for ( i = 1; i <= 10; i += 2 ) // Compliant
for ( i = 1; i != 10; ++i ) // Compliant
Note
For legal reasons, this rule’s description is not part of the public documentation.