Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
C6293
Collapse the table of content
Expand the table of content

C6293

warning C6293: Ill-defined for-loop: counts down from minimum

This warning indicates that a for-loop might not function as intended. It occurs when a loop counts down from a minimum, but has a higher termination condition.

A signed —or unsigned—index variable together with a negative increment will cause the loop to count negative until an overflow occurs. This will terminate the loop.

The following sample code generates this warning:

void f( )
{
   signed char i;
   
   for (i = 0; i < 100; i--)
   {
      // code ...
   }
}

To correct this warning, use the following code:

void f( )
{
   signed char i;
   
   for (i = 0; i < 100; i++)
   {
      // code ...
   }
}
Show:
© 2015 Microsoft