Synopsis: | The variables used in expression 2 of a "for" loop shall not be changed in the loop body and expression 3 at the same time. |
Language: | C |
Severity Level: | 6 |
Category: | Statement and Blocks |
Description: |
Justification
Example 1 for (i = 0; (text[i] != '\0') && (e == OK); i++) /* RIGHT */ { /* Any statement */ e = f(); /* Any statement */ } Example 2 for (i = 0; i < 10; i++) { /* Any statement */ i++; /* WRONG */ /* Any statement */ } Example 3 for (a = 0; text[a] != '\0'; a++) { b = a; ...a...b... /* RIGHT */ } |