www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18918] New: core.internal.hash should perform memberwise


          Issue ID: 18918
           Summary: core.internal.hash should perform memberwise hashing
                    of structs with references
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: n8sh.secondary hotmail.com

So the following passes:

    static struct S { char[] array; }
    auto s1 = S("abc".dup);
    auto s2 = S(s1.array.dup);
    import core.internal.hash : hashOf;
    assert(hashOf(s1) == hashOf(s2));


The eventual goal is to make core.internal.hash usable as a replacement for
`typeid(x).getHash(&x)` that doesn't require runtime type info (useful for
`betterC`) and doesn't ignore `const`-correctness.

May 30 2018