[Issue 9670] New: Shared class object comparison is not yet well defined
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Mar 9 00:09:22 PST 2013
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 at puremagic.com
ReportedBy: k.hara.pg at gmail.com
--- Comment #0 from Kenji Hara <k.hara.pg at 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: -------
More information about the Digitalmars-d-bugs
mailing list