[Issue 669] New: (a == b) misuses opCmp and opEquals
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Dec 9 09:33:43 PST 2006
http://d.puremagic.com/issues/show_bug.cgi?id=669
Summary: (a == b) misuses opCmp and opEquals
Product: D
Version: 0.175
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: burton-radons at smocky.com
This code:
class C
{
override int opEquals (Object other) { return 0; }
override int opCmp (Object other) { return 0; }
}
void main ()
{
auto a = new C, b = new C;
assert (a != b);
}
Asserts, because (a == b) is apparently implemented as (a.opEquals (b) ||
!a.opCmp (b)) for classes. If this were the way it should work, then "float.nan
== 0" would be true. It's the "!<>" operator that's defined with this
behaviour.
--
More information about the Digitalmars-d-bugs
mailing list