August 11, 2005 optimizer bug | ||||
|---|---|---|---|---|
| ||||
Attachments: | If the attached code is compiled without -o, it works fine; when optimized, however, it always produces -nan (regardless of the actual coordinates used). If I change all doubles to reals, it also works fine.. Sorry there's so much code, I couldn't make it shorter while maintaining the bug. The problem is in the line starting with "double tmp=...". xs0 | |||
August 11, 2005 Re: optimizer bug | ||||
|---|---|---|---|---|
| ||||
Posted in reply to xs0 | Well, I did manage to make it shorter :) I was using constants, and they obviously got folded during compilation.. The code below exhibits the same problem.. Again, changing doubles to reals makes it work..
----
import std.stdio;
import std.math;
import std.random;
void main()
{
double x10=rand()*0.000001;
double x11=rand()*0.000001;
double x20=rand()*0.000001;
double x21=rand()*0.000001;
double y10=rand()*0.000001;
double y11=rand()*0.000001;
double y20=rand()*0.000001;
double y21=rand()*0.000001;
double tmp=(x10*x10 + x11*x11 + x20*x20 + x10*(x11 - 2.0*x20 - x21) + x20*x21 + x21*x21 - x11*(x20 + 2.0*x21) + y10*y10 + y10*y11 + y11*y11 - 2.0*y10*y20 - y11*y20 + y20*y20 - y10*y21 - 2.0*y11*y21 + y20*y21 + y21*y21);
writefln(tmp);
}
xs0
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply