Skip to content

Latest commit

 

History

History
49 lines (37 loc) · 1.01 KB

c6293.md

File metadata and controls

49 lines (37 loc) · 1.01 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Warning C6293
Warning C6293
11/04/2016
C6293
LOOP_INDEX_GOES_NEGATIVE
__WARNING_LOOP_INDEX_GOES_NEGATIVE
C6293
24a475f6-fd93-4778-856a-9dd7941f7520

Warning C6293

Ill-defined for-loop: counts down from minimum

Remarks

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, which will terminate the loop.

Code analysis name: LOOP_INDEX_GOES_NEGATIVE

Example

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