[Issue 5080] breaking const-correctness with class/interface

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Feb 9 10:21:09 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=5080


Steven Schveighoffer <schveiguy at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy at yahoo.com


--- Comment #9 from Steven Schveighoffer <schveiguy at yahoo.com> 2011-02-09 10:18:44 PST ---
(In reply to comment #8)
> The patch causes this code to fail to compile:
> ----
> class S { }
> 
> void main()
> {
>     S s1 = new S;
>     const S s2 = new S;
>     assert(s1!=s2);
> }
> ---
> Even so, I think the patch is probably correct -- it's a problem with opEquals.
> But this means that more work is required before this patch could be applied.

That code should fail to compile on the current compiler without patches,
because the prototype for opEquals for objects is:

bool opEquals(Object lhs, Object rhs);

Clearly, this should not accept any const objects.  Because opEquals is special
somehow, the compiler rams it through.

So yeah, that code is not indicative of the patch being bad.

-- 
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