Bug 19332 – hashOf fails to compile for const struct that has non-const toHash & has all fields bitwise-hashable

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-10-25T09:18:46Z
Last change time
2018-10-31T06:39:21Z
Assigned to
No Owner
Creator
Nathan S.

Comments

Comment #0 by n8sh.secondary — 2018-10-25T09:18:46Z
Example: --- struct NotOkay { int canBitwiseHashInts; size_t toHash() /* not const */ { return 0; } } struct Okay { float cantBitwiseHashFloats; size_t toHash() /* not const */ { return 0; } } void main() { const okay = Okay.init; hashOf(okay); // Compiles but writes a message about the non-callable toHash. const notOkay = NotOkay.init; hashOf(notOkay); // Compilation fails! } ---
Comment #1 by n8sh.secondary — 2018-10-25T09:45:08Z
Comment #2 by github-bugzilla — 2018-10-31T06:39:20Z
Commit pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/d380bccfb1629dc99c23cc5d8d668e72d267a34c Fix Issue 19332 - hashOf fails to compile for const struct that has non-const toHash & has all fields bitwise-hashable