www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3916] New: opEquals for objects does not respect const

reply d-bugmail puremagic.com writes:
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
parent d-bugmail puremagic.com writes:
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