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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 7 14:32:30 PST 2011


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


Tomasz Sowiński <tomeksowi at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tomeksowi at gmail.com


--- Comment #6 from Tomasz Sowiński <tomeksowi at gmail.com> 2011-01-07 14:30:10 PST ---
(In reply to comment #3)
> interface I
> {
>     void set(int v);
> }
> class A : I
> {
>     this(int v){val = v;}
>     int val = 10;
>     override void set(int v){val = v;}
> }
> void change(I i)
> {
>     i.set(100);
> }
> void main()
> {
>     auto a = new immutable(A)(10);
>     assert(a.val == 10);
>     change(a);              // immutable(A) is converted to (mutable) I.
>     assert(a.val == 100);   // breaking const-correctness!
> }

Looks like duplicate of bug 3731 (read Steven's comment).

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