[Issue 17639] New: std.math.approxEqual accepts return of isNaN (bool) as argument

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Jul 12 02:59:25 PDT 2017


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

          Issue ID: 17639
           Summary: std.math.approxEqual accepts return of isNaN (bool) as
                    argument
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: drug2004 at bk.ru

Found by typo, forget to remove `isNaN` and code still compiles giving wrong
result:
```
import std.math;

int main()
{
    float a = 0, b = 10_000;

    static assert (!__traits(compiles, q{
            // isNaN wasn't removed during copy-paste
                // but code still compiles with wrong result
        assert (a.approxEqual(b.isNaN) == false);
    }), "This code must not compile!");

    return 0;
}
```

--


More information about the Digitalmars-d-bugs mailing list