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

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)

According to Common Weakness Enumeration, potential errors found by using this diagnostic are classified as CWE-190.


Bugs Found

Checked Projects
384
Collected Errors
13 926
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site. Learn More →
Accept