Bug 12516 – TypeInfo.getHash should not be trusted

Status
NEW
Severity
normal
Priority
P3
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-04-03T16:11:53Z
Last change time
2024-12-07T13:33:37Z
Keywords
safe
Assigned to
No Owner
Creator
David Spies
Moved to GitHub: dmd#17129 →

Comments

Comment #0 by dspies — 2014-04-03T16:11:53Z
When getHash is overridden, it may try to dereference the void pointer, so it's not safe if the pointer is to the wrong type. import std.string; static int x = 35873; @safe void main() { typeid(string).getHash(&x); } --- An example program which segfaults within a @safe method
Comment #1 by bugzilla — 2018-03-12T09:31:25Z
To fix this would probably involve creating a template called getHash2(T)(ref T v) or something like that in TypeInfo, and then using parametric polymorphism on it.
Comment #2 by robert.schadek — 2024-12-07T13:33:37Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17129 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB