| Thread overview | ||||||||
|---|---|---|---|---|---|---|---|---|
|
March 31, 2012 problem compiling with optimizations enabled | ||||
|---|---|---|---|---|
| ||||
I have the following source:
---
import std.stdio;
string ascii = " .:;+=xX$&";
void main()
{
for (idouble i = -2i; i <= 2i; i += .125i)
{
for (double r = -2; r <= 2; r += .0625)
{
auto c = r + i;
auto z = 0 + 0i;
int iter;
do
{
z = z * z + c;
if (z.re * z.re + z.im * z.im > 4)
break;
++iter;
} while (iter < ascii.length - 1);
write(ascii[iter]);
}
writeln();
}
}
---
It compiles and works normally, unless i turn in optimizations:
---
$ dmd -O program.d
Internal error: backend/gloop.c 3400
---
Is this a bug? or something wrong in my code?
compiler: DMD64 D Compiler v2.058 (64 bit)
OS: gentoo linux x86_64
| ||||
April 01, 2012 Re: problem compiling with optimizations enabled | ||||
|---|---|---|---|---|
| ||||
Posted in reply to darkstalker | darkstalker:
> Is this a bug? or something wrong in my code?
Congratulations, it's another compiler bug.
On Windows 32 bit this code behaves in another way, it doesn't crash:
import std.stdio;
void main() {
for (idouble j = -2i; j <= 2i; j += 0.125i) {
for (double r = -2; r <= 2; r += 0.0625) {
cdouble c = r + j;
writeln(c.re, " ", c.im);
}
}
}
Without -O:
-2 -2
-1.9375 -2
-1.875 -2
-1.8125 -2
-1.75 -2
...
1.75 2
1.8125 2
1.875 2
1.9375 2
2 2
With -O:
-0 -9.88131e-324
-0 -9.88131e-324
-0 -9.88131e-324
-0 -9.88131e-324
-0 -9.88131e-324
-0 -9.88131e-324
-0 -9.88131e-324
...
Bye,
bearophile
| |||
April 01, 2012 Re: problem compiling with optimizations enabled | ||||
|---|---|---|---|---|
| ||||
Posted in reply to darkstalker | On 3/31/2012 4:35 PM, darkstalker wrote: > --- > $ dmd -O program.d > Internal error: backend/gloop.c 3400 > --- > > Is this a bug? or something wrong in my code? Any internal error messages are compiler bugs. Please add it to bugzilla: http://d.puremagic.com/issues/enter_bug.cgi?product=D | |||
April 01, 2012 Re: problem compiling with optimizations enabled [OT] | ||||
|---|---|---|---|---|
| ||||
Posted in reply to darkstalker | On Saturday, 31 March 2012 at 23:35:41 UTC, darkstalker wrote: And I have already seen the image in that gravatar somewhere. Bye, bearophile | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply