Thread overview
[Issue 4155] New: return of NaN to temporary fails equality test
Feb 23, 2012
yebblies
Feb 26, 2012
yebblies
Apr 28, 2012
Walter Bright
May 03, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4155

           Summary: return of NaN to temporary fails equality test
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: melvin.curran@googlemail.com


--- Comment #0 from melvin.curran@googlemail.com 2010-05-03 09:06:03 PDT ---
The problem is found in both DMD 1.059 and 2.044 and is demonstrated by the following program - every answer should be false, but that is not the case.

import std.stdio;

T getnan(T)() { return T.nan; }

void main()
{
    float  f = 0.0;
    double d = 0.0;
    real   r = 0.0;

    writefln("before assigning NaN, float:%s, double:%s, real:%s", f, d, r);

    f = getnan!(float)();
    d = getnan!(double)();
    r = getnan!(real)();

    writefln(" float test, literal:%s, assign:%s, temporary:%s", (float.nan ==
0), (f == 0), (getnan!(float)() == 0));
    writefln("double test, literal:%s, assign:%s, temporary:%s", (double.nan ==
0), (d == 0), (getnan!(double)() == 0));
    writefln("  real test, literal:%s, assign:%s, temporary:%s", (real.nan ==
0), (r == 0), (getnan!(real)() == 0));
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 23, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4155


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |yebblies@gmail.com
           Platform|Other                       |x86
         AssignedTo|nobody@puremagic.com        |yebblies@gmail.com
         OS/Version|Windows                     |All
           Severity|normal                      |critical


--- Comment #1 from yebblies <yebblies@gmail.com> 2012-02-24 01:42:51 EST ---
https://github.com/D-Programming-Language/dmd/pull/760

When T is a float or double, and in memory, dmd loads it to gp registers, doubles it, then tests for zero.  When it's in ST(0), dmd uses fucompp to test but the code that tests the flags is unaware of this and doesn't check the zero flag to see if it was a nan comparison.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 26, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4155


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unspecified                 |D1 & D2


--- Comment #2 from yebblies <yebblies@gmail.com> 2012-02-27 03:37:25 EST ---
New pull

https://github.com/D-Programming-Language/dmd/pull/769

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 28, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4155



--- Comment #3 from github-bugzilla@puremagic.com 2012-04-27 18:21:45 PDT ---
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/ac10c87904a73311eba93143d1aa92988227be49 add yebblies fix Issue 4155 - return of NaN to temporary fails equality test

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 28, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4155



--- Comment #4 from github-bugzilla@puremagic.com 2012-04-27 18:21:57 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/e1d597875183f58464ac44b8eb5d3d28f1f90170 add yebblies fix Issue 4155 - return of NaN to temporary fails equality test

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 28, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4155


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


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