The requested page is not available for the requested platform. You are viewing the content for Default platform.

CRR0002 - Suspect variable reference in a For-loop condition

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

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

In the example above, the inner loop should test the variable "j".

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