Summary: NaNs inside associative array don't use normal FP
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: druntime

--- Comment #0 from 2012-04-05 17:45:03 PDT ---
I don't know if this is a bug, or if here D/DMD is working as designed. I am
not sure.

This code shows that floating point NaNs are not tested with == inside
associative arrays (because NaNs != NaNs):

import std.stdio: writeln;
void main() {
    int[double] aa;
    aa[double.nan] = 1;
    aa[double.nan] = 2;

Output DMD 2.059beta:


Python uses == to compare dict (associative array) keys, so NaNs can't
overwrite each other:

>>> a = {}
>>> a[float("nan")] = 1
>>> a
{nan: 1}
>>> a[float("nan")] = 2
>>> a
{nan: 1, nan: 2}

So maybe DMD has to act as Python in this case.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to