I saw this problem in C, then I tried on GDC and have the same problem:

int main() {
   for (uint a = 0, b = 0; a < 6; a += 1, b += 2){
        if (b < a){
            return 1;
        }
   }
   return 0;
}

The code above generates the wrong code when using: -O1, -O2 or -O3:

_Dmain:
        mov     eax, 1
        ret

Changing "uint" to "int" will that, or initializing with both "a" and "b" with a different value like "1" instead of "0" will work in -01, but will keep failing for -02 or -03.

Finally initializing with negative number will work for all 3 optimization level.

Matheus.

Reply via email to