Warning C6294

Ill-defined for-loop: initial condition does not satisfy test. Loop body not executed

Remarks

This warning indicates that a for-loop can't be executed because the terminating condition is true. This warning suggests that the programmer's intent isn't correctly captured.

Code analysis name: LOOP_BODY_NEVER_EXECUTED

Example

The following sample code generates this warning because MAX_VALUE is 0:

#define MAX_VALUE 0
void f()
{
  int i;
  for (i = 0; i < MAX_VALUE; i++)
  {
    // code
  }
}

The following sample code corrects this warning by changing the value of MAX_VALUE to 25

#define MAX_VALUE 25
void f()
{
  int i;
  for (i = 0; i < MAX_VALUE; i++)
  {
    // code
  }
}