[Issue 3916] New: opEquals for objects does not respect const
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Mar 9 11:54:36 PST 2010
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 at puremagic.com
ReportedBy: schveiguy at yahoo.com
--- Comment #0 from Steven Schveighoffer <schveiguy at yahoo.com> 2010-03-09 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: -------
More information about the Digitalmars-d-bugs
mailing list