Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V3113. Consider inspecting the loop...
menu mobile close menu
Additional information
toggle menu Contents

V3113. Consider inspecting the loop expression. It is possible that different variables are used inside initializer and iterator.

Aug 25 2016

The analyzer detected a 'for' operator whose iterator section contains an increment or decrement operation with a variable that is not the counter of that loop.

Consider the following expression:

for (int i = 0; i != N; ++N)

This code is very likely to be incorrect: the 'i' variable should be used instead of 'N' in the increment operation '++N':

for (int i = 0; i != N; ++i)

Another example:

for (int i = N; i >= 0; --N)

This code is also incorrect. The 'i' variable should be decremented instead of 'N':

for (int i = N; i >= 0; --i)

This diagnostic is classified as: