[Issue 669] (a == b) misuses opCmp and opEquals

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 10 14:58:27 PST 2006


http://d.puremagic.com/issues/show_bug.cgi?id=669





------- Comment #3 from smjg at iname.com  2006-12-10 16:58 -------
(In reply to comment #2)
> When it should be implemented like this:
> 
>         int equals(void *p1, void *p2)
>         {
>                 Object o1 = *cast(Object*)p1;
>                 Object o2 = *cast(Object*)p2;
> 
>                 return o1 == o2;
>         }

I could've sworn this was fixed once!  Moreover, that's still not quite right. 
It should be

    int equals(void *p1, void *p2)
    {
        if (p1 == null) return p2 == null;

        Object o1 = *cast(Object*)p1;
        Object o2 = *cast(Object*)p2;

        return o1 == o2;
    }

or some equivalent of this.


-- 



More information about the Digitalmars-d-bugs mailing list