[Issue 7996] New: Refuse std.math.isnan() on not floating point values?

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 27 04:51:41 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7996

           Summary: Refuse std.math.isnan() on not floating point values?
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2012-04-27 04:52:46 PDT ---
std.math.sqrt() refuses an argument of type long (despite this is handy):

import std.math;
void main() {
    long x;
    sqrt(x);
}



With (dmd 2.060alpha):

test.d(4): Error: function std.math.sqrt called with argument types:
    ((long))
matches both:
    std.math.sqrt(float x)
and:
    std.math.sqrt(real x)



While this compiles with no errors:

import std.math;
void main() {
    long x;
    assert(!isnan(x));
}


Maybe isnan() has to statically refuse arguments that aren't built-in floating
point (maybe with a std.traits.isFloatingPoint template constraint), this
avoids some bugs (I have had a bug caused by this).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list