Bug 4589 – comparing two arrays of interfaces for equality segfaults
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2010-08-05T10:50:34Z
Last change time
2019-12-10T13:47:06Z
Assigned to
No Owner
Creator
Steven Schveighoffer
Comments
Comment #0 by schveiguy — 2010-08-05T10:50:34Z
Example case:
interface I
{
}
class C: I
{
this(int x)
{
this.x = x;
}
int x;
override bool opEquals(Object o)
{
if(auto c = cast(C)o)
{
return c.x == x;
}
return false;
}
}
void main()
{
I[] arr;
I[] arr2;
arr ~= new C(1);
arr2 ~= new C(1);
assert(arr == arr2);
}
Note, the opEquals isn't important, but I also want to ensure that after the segfault is removed the correct thing is done. Currently comparing two interfaces for equality does not work.
I'm unsure whether this is a druntime or a dmd problem.
Comment #1 by razvan.nitu1305 — 2019-12-10T13:47:06Z
The code now successfully compiles and runs. closing as fixed.