[Issue 21688] New: CTFE has floats and doubles that exceed float.max and double.max

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 8 10:25:46 UTC 2021


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

          Issue ID: 21688
           Summary: CTFE has floats and doubles that exceed float.max and
                    double.max
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: bugzilla at bernis-buecher.de

With x87 reals available, this unittest passes, although it shouldn't:

```
float f(float a)
{
    return 100*a;
}

unittest
{
    enum f1 = float.max;
    pragma(msg, f(f1));                    // 3.40282e+40F (>float.max)
    pragma(msg, typeof(f(f1)).stringof);   // float

    // at least one of these three asserts should fail,
    // IMHO the last one
    static assert(is (typeof(f(f1)) == float));
    static assert(f(f1) > float.max);
    static assert(f(f1) != float.infinity);
}
```

The same is true for doubles.

--


More information about the Digitalmars-d-bugs mailing list