Bug 9670 – Shared class object comparison is not yet well defined

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-03-09T00:09:20Z
Last change time
2022-09-08T14:24:48Z
Keywords
spec
Assigned to
No Owner
Creator
Kenji Hara

Comments

Comment #0 by k.hara.pg — 2013-03-09T00:09:20Z
With this class definition, class C { static int count; override bool opEquals(Object rhs) { ++count; return true; } } Mutable object comparison calls C.opEquals once. This is expected. C.count = 0; auto mc1 = new C; auto mc2 = new C; assert(mc1 == mc2); assert(C.count == 1); But, in shared object comparison, C.count = 0; auto sc1 = new shared C; auto sc2 = new shared C; assert(sc1 == sc2); // compiles... why? assert(C.count == 1); Mutable opEquals is still called. This is bad hehavior. Moreover, there is another inconsistency. auto so1 = new shared Object; auto so2 = new shared Object; assert(so1 == so2); // fail to compile If you directly compare shared Object class, it fails to compile correctly.
Comment #1 by razvan.nitu1305 — 2022-09-08T14:24:48Z
The shared version of equality comparison does not work today. Closing as fixed.