[Issue 16973] New: `hashOf` has error-prone signature as `(T, seed)` may be confused with `(ptr, length)`
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Dec 15 07:21:06 PST 2016
https://issues.dlang.org/show_bug.cgi?id=16973
Issue ID: 16973
Summary: `hashOf` has error-prone signature as `(T, seed)` may
be confused with `(ptr, length)`
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: major
Priority: P1
Component: druntime
Assignee: nobody at puremagic.com
Reporter: verylonglogin.reg at gmail.com
In our root `object` module we have a function `hashOf` [1] which accept any
type as the first parameter and optional seed as the second parameter.
This function signature is error-prone because its signature allows this
incorrect usage:
---
hashOf(arr.ptr, arr.length); // hash of ptr with seed set to length
---
It's a major issue as (ptr, length) usage pattern is common in programming and
incorrect hash function behavior is hard to debug.
[1] http://dlang.org/phobos/object.html#.hashOf
--
More information about the Digitalmars-d-bugs
mailing list