Udostępnij za pośrednictwem


C6294

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

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

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