Bug 1873 – structs with at least one immutable member are completely immutable
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2008-02-27T02:26:00Z
Last change time
2015-06-09T01:14:35Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
sludwig
Comments
Comment #0 by sludwig — 2008-02-27T02:26:17Z
The following code fails to compile, although 'x' should be mutable:
struct S {
invariant int dummy; // const gives the same result
int x;
}
int main(){
S s;
s.x = 1; // error: cannot modify struct with immutable members
return 0;
}