www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6537] New: OS X optimizer bug (?)

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6537

           Summary: OS X optimizer bug (?)
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Mac OS X
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: code klickverbot.at


--- Comment #0 from klickverbot <code klickverbot.at> 2011-08-20 06:47:28 PDT
---
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).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 20 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6537


klickverbot <code klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code


--- Comment #1 from klickverbot <code klickverbot.at> 2011-08-20 07:02:42 PDT
---
This also happens when explicitly using GCC 4.2, so it's not a case of DMD
getting miscompiled by LLVM-GCC/Clang.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 20 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6537


Jacob Carlborg <doob me.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |doob me.com


--- Comment #2 from Jacob Carlborg <doob me.com> 2011-08-20 08:26:16 PDT ---
I can reproduce it on Mac OS X 10.6.8.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 20 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6537


klickverbot <code klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |critical


--- Comment #3 from klickverbot <code klickverbot.at> 2011-08-20 08:28:40 PDT
---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 20 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6537



--- Comment #4 from klickverbot <code klickverbot.at> 2011-08-20 08:31:14 PDT
---
Forgot to mention: I'm at DMD c98b611, druntime a59dd37, Phobos dff57f1.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 20 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6537



--- Comment #5 from Jacob Carlborg <doob me.com> 2011-08-20 08:53:54 PDT ---
I'm using the 2.054 release.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 20 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6537


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au


--- Comment #6 from Don <clugdbug yahoo.com.au> 2011-10-13 23:18:02 PDT ---
This sounds a lot like bug 5364.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 13 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6537


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com


--- Comment #7 from Walter Bright <bugzilla digitalmars.com> 2011-11-18
00:59:46 PST ---
(In reply to comment #6)
 This sounds a lot like bug 5364.

Since 5364 is fixed now, please try it again on OS X. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 18 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6537


klickverbot <code klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #8 from klickverbot <code klickverbot.at> 2011-11-18 08:32:03 PST
---
Fixed in Git master.

*** This issue has been marked as a duplicate of issue 5364 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 18 2011