www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2948] New: Array literal changeable if part of class.

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: georg 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
}


-- 
May 06 2009
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2948


gide nwawudu.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE




------- Comment #1 from gide nwawudu.com  2009-05-07 03:32 -------


*** This bug has been marked as a duplicate of 2947 ***


-- 
May 07 2009