March 09, 2013 [Issue 9670] New: Shared class object comparison is not yet well defined | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=9670 Summary: Shared class object comparison is not yet well defined Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: spec Severity: major Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: k.hara.pg@gmail.com --- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2013-03-09 00:09:20 PST --- 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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation