Bug 18357 – can break immutable with postblit

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-02-02T11:58:46Z
Last change time
2024-12-13T18:56:35Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
ag0aep6g
Moved to GitHub: dmd#19376 →

Comments

Comment #0 by ag0aep6g — 2018-02-02T11:58:46Z
---- 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 */ } ----
Comment #1 by ag0aep6g — 2018-03-06T12:56:29Z
*** Issue 18561 has been marked as a duplicate of this issue. ***
Comment #2 by andrei — 2018-03-19T15:57:47Z
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 */ }
Comment #3 by dfj1esp02 — 2018-04-03T07:45:44Z
Postblit should respect type qualifiers the same way const constructor does.
Comment #4 by robert.schadek — 2024-12-13T18:56:35Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19376 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB