www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Object typeinfo bug with null and ==, !=

I think there's a bug in ti_C.d in TypeInfo_C.equals() and compare(). The
line
 return o1 == o2 || (o1 && o1.opCmp(o2) == 0);
should be something like
 return o1 is o2 || (o1 && o1.opEquals(o2) != 0) || (o1 && o1.opCmp(o2) ==
0);
since o1 == o2 will seg-v if o1 is null.

The same goes for compare() with the code
        // Regard null references as always being "less than"
        if (o1 != o2)
It should be !==. Either that or the comment should be something like
        // Regard null references as seg-v

Then again it always seemed wierd that x != null will seg-v if x is null.
Maybe that is what needs attention rather than ti_C.d

-Ben
Aug 07 2004