TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
ASML C Coding Standard
Search

Rule:  6.8.5.1.aChecked automatically with code checker

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 */
}