Bug 5327 – Creating new struct with literal bypasses immutability of members of members of the struct

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-12-06T03:53:00Z
Last change time
2011-06-11T20:17:15Z
Keywords
accepts-invalid, spec
Assigned to
nobody
Creator
zan77137
Blocks
2573

Comments

Comment #0 by zan77137 — 2010-12-06T03:53:59Z
This code shouldn't work: ------------------------------ import std.stdio; struct ID { immutable int value; } struct Data { ID id; } void main() { Data data = Data(ID(1)); immutable int* val = &data.id.value; writeln(*val); // 1 data = Data(ID(2)); // <- This line shouldn't be allowed. writeln(*val); // 2 }
Comment #1 by smjg — 2010-12-07T04:07:26Z
There are several bugs that match the summary line you had. See issue 2573. This is closely related to issue 2625. The solution is given in issue 2625 comment 4.
Comment #2 by bugzilla — 2011-06-11T20:17:15Z