www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13052] New: TypeInfo.getHash should return same hash for


          Issue ID: 13052
           Summary: TypeInfo.getHash should return same hash for different
                    floating point zeros.
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: k.hara.pg gmail.com

Test case:

void main()
    alias F = float;

    F f1 = +0.0, f2 = -0.0;
    assert(f1 !is f2);   // they have different bit representations
    assert(f1  == f2);   // but they are equal

    TypeInfo ti = typeid(F);
    assert(ti.getHash(&f1) == ti.getHash(&f2));
    // if f1 and f2 are equal, their hash values should also be equal

Jul 05 2014