...
This noncompliant code example appears to iterate five times. However, the loop never terminates because the successive values of i
are 1, 3, 5, 7, 9 and 11, allowing the comparison with 10 to be skipped. On a Java based system, the value reaches the maximum representable positive number (Integer.MAX_VALUE
) and on subsequent incrementing, wraps to the second lowest negative number (Integer.MIN_VALUE
- + 1). It then works its way up to -1, then 1, and proceeds as described earlier.
...