digitalmars.D.bugs - [Issue 3916] New: opEquals for objects does not respect const
- d-bugmail puremagic.com (37/37) Mar 09 2010 http://d.puremagic.com/issues/show_bug.cgi?id=3916
- d-bugmail puremagic.com (12/12) Apr 12 2011 http://d.puremagic.com/issues/show_bug.cgi?id=3916
http://d.puremagic.com/issues/show_bug.cgi?id=3916 Summary: opEquals for objects does not respect const Product: D Version: 2.041 Platform: Other OS/Version: All Status: NEW Severity: major Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: schveiguy yahoo.com 11:54:35 PST --- Example: class C { int x; bool opEquals(Object d) {++x; return false;} } void main() { const c1= new C; const c2= new C; assert(c1 != c2); assert(c1.x == 1); } This should fail to compile. I'm unsure what the correct signature for opEquals should be, but I'd expect it to be something like: bool opEquals(const Object other) const; With the global function being changed to: bool opEquals(const Object lhs, const Object rhs); This may limit the ability to run cached calculations in the objects themselves during comparisons, but I think this situation could be worked around with casts. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 09 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3916 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |k.hara.pg gmail.com Resolution| |DUPLICATE *** This issue has been marked as a duplicate of issue 1824 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 12 2011