Bug when using uint inside loop
Matheus
matheus at gmail.com
Sat Oct 9 14:52:47 UTC 2021
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.
More information about the D.gnu
mailing list