Bug 6537 – OS X optimizer bug (?)

Status
RESOLVED
Resolution
DUPLICATE
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2011-08-20T06:47:00Z
Last change time
2011-11-18T08:32:03Z
Keywords
wrong-code
Assigned to
nobody
Creator
code

Comments

Comment #0 by code — 2011-08-20T06:47:28Z
to!string() seems to produce wrong results with -O using current DMD here on my OS X Lion box: --- import std.conv; import std.stdio; void main() { writefln("%s %s", long.min, to!string(long.min)); } --- If I build the snippet without compiler flags, it prints (as expected): -9223372036854775808 -9223372036854775808 If I add -O, however, the output becomes: -9223372036854775808 -9223372032559808512 It seems like the lower 32 bits are zeroed out in the to!string() version (the problem occurs also when to!string is used in isolation, the writefln is just for demonstrative purposes). Interestingly, this only occurs on my OS X box, I can't reproduce this in a Linux VM (neither on x86 nor x86_64).
Comment #1 by code — 2011-08-20T07:02:42Z
This also happens when explicitly using GCC 4.2, so it's not a case of DMD getting miscompiled by LLVM-GCC/Clang.
Comment #2 by doob — 2011-08-20T08:26:16Z
I can reproduce it on Mac OS X 10.6.8.
Comment #3 by code — 2011-08-20T08:28:40Z
Thanks Jacob, raising the importance to critical. It seems to happen for numbers smaller than int.min, but I haven't scanned the whole range or anything.
Comment #4 by code — 2011-08-20T08:31:14Z
Forgot to mention: I'm at DMD c98b611, druntime a59dd37, Phobos dff57f1.
Comment #5 by doob — 2011-08-20T08:53:54Z
I'm using the 2.054 release.
Comment #6 by clugdbug — 2011-10-13T23:18:02Z
This sounds a lot like bug 5364.
Comment #7 by bugzilla — 2011-11-18T00:59:46Z
(In reply to comment #6) > This sounds a lot like bug 5364. Since 5364 is fixed now, please try it again on OS X.
Comment #8 by code — 2011-11-18T08:32:03Z
Fixed in Git master. *** This issue has been marked as a duplicate of issue 5364 ***