Bug 15612 – Break immutability with default initialisers

Status
RESOLVED
Resolution
DUPLICATE
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-01-26T08:25:20Z
Last change time
2024-06-07T10:04:30Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
John Colvin
See also
https://issues.dlang.org/show_bug.cgi?id=17604, https://issues.dlang.org/show_bug.cgi?id=2947

Comments

Comment #0 by john.loughran.colvin — 2016-01-26T08:25:20Z
void main() { immutable S s0; S s1; assert(s0.c.a == 42); s1.c.a = -42; assert(s0.c.a == 42); //FAILS! } struct S { C c = new C(42); } class C { int a; this(int a) { this.a = a; } }
Comment #1 by nick — 2024-06-07T10:04:30Z
*** This issue has been marked as a duplicate of issue 10376 ***