[Issue 2948] New: Array literal changeable if part of class.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed May 6 23:35:27 PDT 2009


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

           Summary: Array literal changeable if part of class.
           Product: D
           Version: 2.029
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: georg at iki.fi


import std.stdio;

class A
{
    int[] c = [3,3];
}

void main()
{
    int[] a = [2,2];
    int[] b = [2,2];
    a[0] = 33;
    assert(b[0] == 2);   // success

    A ca = new A;
    A cb = new A;
    ca.c[0] = 44;
    assert(cb.c[0] == 3); // failure: value is 44
}


-- 



More information about the Digitalmars-d-bugs mailing list