Bug 17682 – can break immutable with destructor

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-07-25T10:01:22Z
Last change time
2024-12-13T18:53:37Z
Keywords
accepts-invalid, safe
Assigned to
No Owner
Creator
ag0aep6g
Moved to GitHub: dmd#19288 →

Comments

Comment #0 by ag0aep6g — 2017-07-25T10:01:22Z
Should be rejected: ---- struct S { int* p; ~this() @safe { if (p) *p = 13; } } void main() @safe { immutable int* i = new int(42); assert(*i == 42); /* passes */ { auto s = immutable S(i); } assert(*i == 42); /* fails; it's 13 now */ } ----
Comment #1 by robert.schadek — 2024-12-13T18:53:37Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19288 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB