Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V7032. The loop counter is compared...
menu mobile close menu
Additional information
toggle menu Contents

V7032. The loop counter is compared to its own initial value.

Aug 04 2026

The analyzer has detected a for loop where the initial and final values of the iterator are the same. This looks like a typo. As a result, the loop either won't execute or will execute only once.

The example:

function copy_range(src, dst, from, to) {
  for (let i = from; i < from; i++) {
    dst[i] = src[i];
  }
}

The function should copy the elements in the from to to range between the collections. In reality, the loop body never executes: the i < from condition is false, since i starts at from. This is a typo, and the condition should use a different variable—in this case, to.

The fixed code:

function copy_range(src, dst, from, to) {
  for (let i = from; i < to; i++) {
    dst[i] = src[i];
  }
}

What a quick draw in the Wild West of Coding —
you caught the bug in sec!
But we catch them in milliseconds. How about a duel?

Try free