Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V683. The 'i' variable should...
menu mobile close menu
Additional information
toggle menu Contents

V683. The 'i' variable should probably be incremented instead of the 'n' variable. Consider inspecting the loop expression.

Dec 01 2013

The analyzer has detected a potential error in a loop: there may be a typo which causes a wrong variable to be incremented/decremented.

For example:

void Foo(float *Array, size_t n)
{
  for (size_t i = 0; i != n; ++n)
  { 
    ....
  }
}

The variable 'n' is incremented instead of the variable 'i'. It results in an unexpected program behavior.

This is the fixed code:

for (size_t i = 0; i != n; ++i)

This diagnostic is classified as: