Nous utilisons des cookies pour améliorer votre expérience de navigation. En savoir plus
Accepter
to the top

Webinar: Let's make a programming language. Part 1. Intro - 20.02

>
>
>
V654. Condition of a loop is always...
menu mobile close menu
Additional information
toggle menu Contents

V654. Condition of a loop is always true/false.

06 Déc 2012

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)
{ .... }

This diagnostic is classified as:

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