Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Ill-defined for-loop. Loop body only executed once.
Remarks
This warning indicates that a for-loop might unintentionally execute only once. A loop with an unsigned index counting down from zero or a mistaken use of ==
might cause this warning.
Code analysis name: LOOP_ONLY_EXECUTED_ONCE
Example
The following example generates C6296. Each for-loop shown executes exactly once.
int main()
{
for (unsigned int i = 0; i < 10; i--) {} // C6296
// Use the following line to resolve the warning:
// for (unsigned int i = 0; i < 10; i++) {}
for (int i = 0; i == 0; i++) {} // C6296
for (int i = 0; i < 1; i++) {} // OK
for (int i = 1; i > 0; i--) {} // OK
}