digitalmars.D.bugs - [Issue 14618] New: can break immutable with inout and a delegate
- via Digitalmars-d-bugs (35/35) May 23 2015 https://issues.dlang.org/show_bug.cgi?id=14618
https://issues.dlang.org/show_bug.cgi?id=14618 Issue ID: 14618 Summary: can break immutable with inout and a delegate Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: accepts-invalid Severity: normal Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: ag0aep6g gmail.com struct S { immutable(int)* p; } inout(int)* f(inout S s) { inout(int)* result; auto dg = (inout(int)* p) {result = p;}; dg(s.p); return result; } void main() { immutable int x = 42; immutable int* p = &x; assert(*p == 42); /* passes */ scope(exit) assert(*p == 42); /* fails */ int* m = f(S(p)); /* uh-oh */ *m = 13; /* writing over immutable *p */ } --
May 23 2015