Bug 15367 – array of delegates comparison fails

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-11-20T12:04:02Z
Last change time
2018-01-05T13:27:02Z
Keywords
wrong-code
Assigned to
No Owner
Creator
Marenz

Comments

Comment #0 by dmdtracker — 2015-11-20T12:04:02Z
To my understanding the code below should work, however the assert fails. module main; void main() { void a () {} void b () {} auto array = [&b, &a]; auto array2 = [&b, &a]; for (auto i = 0; i < 2; i++) assert(array[i] == array2[i]); assert(array == array2); // Assert failure }
Comment #1 by ketmar — 2015-11-20T12:32:41Z
and a fix: diff --git a/src/object.d b/src/object.d index 4ce7670..84de07a 100644 --- a/src/object.d +++ b/src/object.d @@ -770,6 +770,12 @@ class TypeInfo_Delegate : TypeInfo return c && this.deco == c.deco; } + override bool equals(in void* p1, in void* p2) const + { + alias dg = void delegate (int); + return *cast(dg *)p1 == *cast(dg *)p2; + } + // BUG: need to add the rest of the functions override @property size_t tsize() nothrow pure const
Comment #2 by k.hara.pg — 2015-11-20T13:08:39Z
Comment #3 by github-bugzilla — 2015-11-20T14:50:13Z
Commits pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/cbaca5965e9af6e774c3f2c87e55da007b6d1585 fix Issue 15367 - array of delegates comparison fails https://github.com/D-Programming-Language/druntime/commit/8b2debc5a64aec2e37dfbceb15a8b01f2904bf37 Merge pull request #1436 from 9rnsr/fix15367 Issue 15367 - array of delegates comparison fails
Comment #4 by github-bugzilla — 2016-01-03T14:10:13Z
Comment #5 by github-bugzilla — 2018-01-05T13:27:02Z
Commits pushed to dmd-cxx at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/cbaca5965e9af6e774c3f2c87e55da007b6d1585 fix Issue 15367 - array of delegates comparison fails https://github.com/dlang/druntime/commit/8b2debc5a64aec2e37dfbceb15a8b01f2904bf37 Merge pull request #1436 from 9rnsr/fix15367