Code inspection: Loop control variable is never changed inside loop
Last modified: 11 February 2024tip
This inspection reports loops that are not constrained — they either fail immediately or run indefinitely. In the following code snippet
the loop variable condition
is not varying, which causes the loop to execute indefinitely (unless for instance an exception occurs). In this synthetic example the problem is obvious, but if there is a lot of code inside the loop, you might never notice that until the program hangs at runtime.