www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21772] New: [REG2.069] Consecutive different-signed

https://issues.dlang.org/show_bug.cgi?id=21772

          Issue ID: 21772
           Summary: [REG2.069] Consecutive different-signed `double.nan`s
                    in an array literal take the sign of the previous nan
                    (same for `float` and `real`)
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: n8sh.secondary hotmail.com

Demonstration below. Bug does not appear in LDC.

---
void main()
{
    import std.stdio : writeln;
    import std.math : isIdentical;

    double[] a = [-double.nan, double.nan,  double.nan,
                          1.0, double.nan, -double.nan];
    writeln(a); // Writes "[-nan, -nan, -nan, 1, nan, nan]" (Uh-oh!)
    assert(!isIdentical(a[0], a[1])); // Fails of course.
}
---

--
Mar 27