V654. The condition of loop is always true/false.

The analyzer has detected an issue when the condition in the 'for' or 'while' operator is always true or always false. It usually indicates presence of errors. It's highly probable that the programmer made a misprint when writing the code and this fragment should be examined.

Consider an example of incorrect code:

for (i = 0; 1 < 50; i++)
{ .... } 

There is a misprint there. In the condition, the constant '1' is written instead of the 'i' variable. This code is easy to fix:

for (i = 0; i < 50; i++)
{ .... } 

The analyzer won't generate the warning message if the condition is defined explicitly as a constant expression '1' or '0', 'true' or 'false'. For example:

while (true)
{ .... }

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

You can look at examples of errors detected by the V654 diagnostic.

Bugs Found

Checked Projects
Collected Errors
12 668