[Issue 4251] New: const(T) is appendable to const(T)[]

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun May 30 04:11:19 PDT 2010


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

           Summary: const(T) is appendable to const(T)[]
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: pelle.mansson at gmail.com


--- Comment #0 from Pelle Månsson <pelle.mansson at gmail.com> 2010-05-30 04:11:17 PDT ---
void messwith(T)(ref const(T)[] ts, const(T) t) {
    ts ~= t;
}

class C {
    int x;
    this(int i) { x = i; }
}

void main(string[] args) {

    C[] cs;
    immutable C ci = new immutable(C)(6);

    assert (ci.x == 6);

    messwith(cs,ci);

    cs[$-1].x = 14;

    assert (ci.x == 14); //whoops.
}

I'm pretty sure you shouldn't be able to do that.

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