[Issue 5080] breaking const-correctness with class/interface
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Oct 19 08:09:19 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5080
--- Comment #3 from Kenji Hara <k.hara.pg at gmail.com> 2010-10-19 08:08:39 PDT ---
This code should not work.
----
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!
}
----
--
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