October 09, 2021 Bug when using uint inside loop | ||||
---|---|---|---|---|
| ||||
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. |
October 09, 2021 Re: Bug when using uint inside loop | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matheus | On Saturday, 9 October 2021 at 14:52:47 UTC, Matheus wrote: > 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. > Nothing I can really do about that, it's occurring outside of the D front-end. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100740 |
Copyright © 1999-2021 by the D Language Foundation