To compile this code with '-release -O' brings a incorrect calculation.
import std.stdio;
int x = 2, y = 1;
void main() {
int res = 0;
for(int i = 0; i < 10; i++) {
res = res + x - y;
writefln(res);
}
}
Comment #1 by jpelcis — 2006-09-06T17:46:20Z
-release isn't required. Only -O is needed for the bug.
This error also occurs in DMC with similar code.
The error will disappear if x is of any other type except uint, y is a long or ulong, or res is a byte, ubyte, long, or ulong. Casting to those types also gets rid of the bug.
I hope that helps.