January 14, 2004 [BUG] uint division is performed as int division | ||||
|---|---|---|---|---|
| ||||
With -O option, uint division is performed as int division.
int main() {
uint f(uint n) { return n % 10; }
printf("%u\n", uint.max);
printf("%u\n", f(uint.max));
printf("%d\n", uint.max);
printf("%d\n", f(uint.max));
return 0;
}
Without -O:
4294967295
5
-1
5
With -O:
4294967295
4294967295
-1
-1
If the division is performed directly (i.e. uint.max % 10),
it works both with and without -O option.
This is a bug of inline expansion, isn't it?
| ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply