Thread overview
[Issue 5999] New: Inconsistent equality with array of NaNs between runtime and CTFE
May 14, 2011
kennytm@gmail.com
Jun 14, 2011
Paul D. Anderson
Jun 14, 2011
Don
Jan 21, 2012
Walter Bright
May 14, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5999

           Summary: Inconsistent equality with array of NaNs between
                    runtime and CTFE
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Mac OS X
            Status: NEW
          Keywords: wrong-code
          Severity: minor
          Priority: P2
         Component: druntime
        AssignedTo: nobody@puremagic.com
        ReportedBy: kennytm@gmail.com


--- Comment #0 from kennytm@gmail.com 2011-05-14 07:33:25 PDT ---
In CTFE, an array of NaN will not be equal to itself. However, this return 'true' in the runtime:

-----------------------------------------------
bool f() {
    float[] h = [float.nan];
    float[] i = [float.nan];
    return h == i;
}
void main() {
    static assert(!f());    // ctfe is OK
    assert(!f());           // runtime asserts
}
-----------------------------------------------

The CTFE and runtime result should be consistent.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 14, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5999


Paul D. Anderson <paul.d.anderson@comcast.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paul.d.anderson@comcast.net


--- Comment #1 from Paul D. Anderson <paul.d.anderson@comcast.net> 2011-06-14 14:01:19 PDT ---
At the risk of stating the obvious, the correct result for a NaN compared to itself is false. I would assume (correct me if I'm wrong) that an array of NaN compared to itself would therefore also be false, since each element is != to itself. That is, the runtime assert is correct and the CTFE is incorrect.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 14, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5999


Don <clugdbug@yahoo.com.au> changed:

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


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2011-06-14 14:22:33 PDT ---
(In reply to comment #1)
> At the risk of stating the obvious, the correct result for a NaN compared to itself is false. I would assume (correct me if I'm wrong) that an array of NaN compared to itself would therefore also be false, since each element is != to itself.

Yes.

>That is, the runtime assert is correct and the CTFE is incorrect.

I think you misread the code. CTFE returns not equal, runtime returns equal.

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


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2012-01-20 22:05:03 PST ---
Yes, the runtime is in error here.

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