D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4589 - comparing two arrays of interfaces for equality segfaults
Summary: comparing two arrays of interfaces for equality segfaults
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Linux
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-05 10:50 UTC by Steven Schveighoffer
Modified: 2019-12-10 13:47 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Steven Schveighoffer 2010-08-05 10:50:34 UTC
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 RazvanN 2019-12-10 13:47:06 UTC
The code now successfully compiles and runs. closing as fixed.