www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21688] New: CTFE has floats and doubles that exceed float.max


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

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

float f(float a)
    return 100*a;

    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.

Mar 08 2021