Skip to main content

CRR0003 - Suspect variable reference in the For-loop iterator section

This analyzer detects mistakes made in the for loop iterator expression. For instance, the for loop can increment one variable, but test another. This may lead to an incorrect number of iterations or even an infinite loop. It’s easy to make such a mistake when editing a copy of another loop.

for (int i = 0; i < n1; i++) {
    for(int j = 0; j < n2; i++) { // CRR0003
        // ...
    }
}

In the example above, the inner loop should increment variable “j“.

for (int i = 0; i < n1; i++) {
    for(int j = 0; j < n2; j++) {
        // ...
    }
}