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.aChecked automatically with code checker

Synopsis:The termination condition of iteration shall not have a constant value.
Language:C
Severity Level:4
Category:Statement and Blocks


Description:

Justification

Avoid unintended dead code or infinite loops.

Example 1

#define TEST (false)

while (TEST) /* WRONG */
{
   /* Any statement */
}

Example 2

#define TEST (false)

for (i = 0; TEST; i++) /* WRONG */
{
   /* Any statement */
}

Example 3

/* infinite loop */
for (;;) /* RIGHT */
{
   /* Any statement */
}

Note

When an infinite loop is needed use for (;;) instead.

An exception is made for the "do {} while (0)" construct used in header files for macros.