https://issues.dlang.org/show_bug.cgi?id=18357

          Issue ID: 18357
           Summary: can break immutable with postblit
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nob...@puremagic.com
          Reporter: ag0ae...@gmail.com

----
struct S
{
    int* x;
    this(this) @safe { *x = 13; }
}

void main() @safe
{
    immutable int* x = new int(42);
    assert(*x == 42); /* passes */
    auto s = immutable S(x);
    auto s2 = s; /* should be rejected */
    assert(*x == 42); /* fails */
}
----

--

Reply via email to