As discussed in this thread:
http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D.learn&artnum=31864
Shorter version of the bug:
import std.stdio;
void calculate1(float a, float b)
{
float s1 = 1.0f - a;
float s2 = a * b;
writeln(s2);
writeln(a * b);
}
void calculate2(float a, float b)
{
float s1 = 1.0 - a;
float s2 = a * b;
writeln(s2);
writeln(a * b);
}
void calculate3(double a, double b)
{
double s1 = 1.0 - a;
double s2 = a * b;
writeln(s2);
writeln(a * b);
}
int main()
{
writeln("calculate1:");
calculate1(0.75f,2.0f);
writeln("calculate2:");
calculate2(0.75f,2.0f);
writeln("calculate3:");
calculate3(0.75f,2.0f);
return 0;
}
-------------------------------------------------
+ The complete output
-------------------------------------------------
calculate1:
1.5
1.5
calculate2:
0
1.5
calculate3:
1.5
1.5
Comment #1 by bugzilla — 2012-01-27T01:40:06Z
I tried this on Ubuntu Linux with the latest build:
dmd foo -O
dmd foo
dmd foo -O -inline
and could not reproduce an error. The generated code looks fine, too.
Comment #2 by issues.dlang — 2012-01-27T02:01:59Z
I see it on 2.057 without -inline or -O (the problem seems to go away with either of those flags), but I don't see it at all on the latest from github. This using using 64-bit Arch Linux.
Comment #3 by bugzilla — 2012-01-27T09:23:42Z
Ok, so without further evidence it is not working in the latest build, I'm going to resolve this.