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
Comment #2 by github-bugzilla — 2018-07-02T21:13:05Z
Commits pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/22a6f7fd5a107040d822c96a2e5725dadb4c1763 Fix Issue 18918 - core.internal.hash should perform memberwise hashing of structs with references https://github.com/dlang/druntime/commit/63efdeffb06b5656ff834aaf34e71d30bb989863 Merge pull request #2195 from n8sh/core-hash-18918 Fix Issue 18918 - core.internal.hash should perform memberwise hashing of structs with references merged-on-behalf-of: Sebastian Wilzbach <[email protected]>