[Issue 18357] New: can break immutable with postblit
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Feb 2 11:58:46 UTC 2018
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: nobody at puremagic.com
Reporter: ag0aep6g at 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 */
}
----
--
More information about the Digitalmars-d-bugs
mailing list