Bug 16974 – [REG2.068] Equal associative arrays with associative array keys are considered unequal

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-12-15T16:13:00Z
Last change time
2017-01-16T23:24:45Z
Keywords
wrong-code
Assigned to
nobody
Creator
verylonglogin.reg

Comments

Comment #0 by verylonglogin.reg — 2016-12-15T16:13:35Z
This code should run fine: --- void main() { int[int] a = [1 : 2]; assert([a : 3] == [a : 3]); // fails assert([a : 3] == [[1 : 2] : 3]); // fails } ---
Comment #1 by verylonglogin.reg — 2016-12-15T16:26:12Z
The reason is incorrect hash calculation: --- int[int] a = [1 : 2]; assert(typeid(a).getHash(&a) == typeid(a).getHash(&a)); // fails --- Opened druntime pull 1715 [1]. This incorrect hash calculation became possible because of `hashOf` signature, see Issue 16973. [1] https://github.com/dlang/druntime/pull/1715
Comment #2 by safety0ff.bugz — 2016-12-16T02:09:56Z
You've marked this as a regression, which version did this previously work in?
Comment #3 by verylonglogin.reg — 2016-12-16T10:24:14Z
(In reply to safety0ff.bugz from comment #2) > You've marked this as a regression, which version did this previously work > in? Because at least before 79bc91b41334c1805f557ef2f1606de31c6764d1 [1] `rt.util.hash.hashOf` was used in `_aaGetHash`. Though I didn't actually test it. [1] https://github.com/dlang/druntime/commit/79bc91b41334c1805f557ef2f1606de31c6764d1
Comment #4 by verylonglogin.reg — 2016-12-16T12:59:29Z
(In reply to Denis Shelomovskii from comment #3) > Though I didn't actually My friend's code which worked around 2.5 years ago is now broken.
Comment #5 by safety0ff.bugz — 2016-12-16T16:25:03Z
(In reply to Denis Shelomovskii from comment #3) > > Because at least before 79bc91b41334c1805f557ef2f1606de31c6764d1 [1] > `rt.util.hash.hashOf` was used in `_aaGetHash`. Though I didn't actually > test it. Ah, yea, I see the import was removed, good enough for me.
Comment #6 by github-bugzilla — 2016-12-28T00:09:57Z
Commits pushed to stable at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/5cc28431b92d6849ef7758d200f714f5aee996f3 Fix Issue 16974 - Equal associative arrays with associative array keys are considered unequal Use correct overload of `hashOf` in `_aaGetHash`. This incorrect usage is possible because of Issue 16973 - `hashOf` has error-prone signature as `(T, seed)` may be confused with `(ptr, length)` [1]. [1] https://issues.dlang.org/show_bug.cgi?id=16973 https://github.com/dlang/druntime/commit/d57fdb116ebb9dc1a7c0f1983c253db58dbbc22b Merge pull request #1715 from denis-sh/fix-Issue-16974 [REG2.068] Fix Issue 16974 - Equal associative arrays with associative array keys are considered unequal
Comment #7 by github-bugzilla — 2017-01-15T02:36:21Z
Commits pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/5cc28431b92d6849ef7758d200f714f5aee996f3 Fix Issue 16974 - Equal associative arrays with associative array keys are considered unequal https://github.com/dlang/druntime/commit/d57fdb116ebb9dc1a7c0f1983c253db58dbbc22b Merge pull request #1715 from denis-sh/fix-Issue-16974
Comment #8 by github-bugzilla — 2017-01-16T23:24:45Z
Commits pushed to newCTFE at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/5cc28431b92d6849ef7758d200f714f5aee996f3 Fix Issue 16974 - Equal associative arrays with associative array keys are considered unequal https://github.com/dlang/druntime/commit/d57fdb116ebb9dc1a7c0f1983c253db58dbbc22b Merge pull request #1715 from denis-sh/fix-Issue-16974