[Issue 18357] can break immutable with postblit

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 19 15:57:47 UTC 2018


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

Andrei Alexandrescu <andrei at erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei at erdani.com

--- Comment #2 from Andrei Alexandrescu <andrei at erdani.com> ---
A similar example shows fetching a mutable pointer to immutable data:

----
int* g;

struct S
{
    int* x;
    this(this) { g = x; }
}

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

--


More information about the Digitalmars-d-bugs mailing list