Created attachment 1083
code that produces the bug
The program attached compiles and works normally, unless compiled with
optimizations enabled:
$ dmd -O bug.d
Internal error: backend/gloop.c 3400
---
compiler: DMD64 D Compiler v2.058
OS: gentoo linux x86_64
Comment #1 by bearophile_hugs — 2012-04-01T03:47:57Z
On Windows 32 bit, with DMD 2.059head it doesn't crash, but it outputs:
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
...
Comment #2 by clugdbug — 2012-04-03T06:58:35Z
Code in the attachement
----
import std.stdio;
void main()
{
for (idouble i = -2i; i <= 2i; i += .125i)
for (double r = -2; r <= 2; r += .0625)
{
cdouble c = r + i;
writeln(c);
}
}
---
Comment #3 by bugzilla — 2013-10-04T12:40:44Z
A simpler version without all the templates:
import core.stdc.stdio;
void main()
{
for (idouble i = -2i; i <= 2i; i += .125i)
for (double r = -2; r <= 2; r += .0625)
{
cdouble c = r + i;
printf("%g %gi\n", c.re, c.im);
}
}
Which does not produce an internal error with -O, but does go into an infinite loop when the compiled program is executed.