The following code bypasses immutabililty with GDC but not DMD
Nicholas Smith
nmsmith65 at gmail.com
Thu Apr 11 17:50:02 PDT 2013
I don't know how to file bug reports but I'm sure this shouldn't
happen :)
DMD gives an error.
import std.stdio;
void main()
{
immutable Cat cat = cast(immutable) new Cat(5);
happyBirthday(cat.age);
writefln("My 5 year old cat is %s years old!", cat.age);
}
void happyBirthday(ref int i)
{
i++;
}
class Cat
{
public int age;
this(int a)
{
this.age = age;
}
}
Output:
My 5 year old cat is 6 years old!
More information about the D.gnu
mailing list