Bug 18918 – core.internal.hash should perform memberwise hashing of structs with references
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-05-30T19:40:18Z
Last change time
2018-07-02T21:13:06Z
Assigned to
No Owner
Creator
Nathan S.
Comments
Comment #0 by n8sh.secondary — 2018-05-30T19:40:18Z
So the following passes:
```d
unittest
{
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.
Comment #1 by n8sh.secondary — 2018-05-30T20:13:18Z