Bug 1801 – Const structs should be assignable to non-const variables unless they contain references

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2008-01-23T05:09:00Z
Last change time
2015-06-09T01:14:30Z
Keywords
rejects-valid, spec
Assigned to
bugzilla
Creator
sludwig

Comments

Comment #0 by sludwig — 2008-01-23T05:09:56Z
For structs not containing any reference values (like pointers, class references, arrays etc.) and have not fields which are not assignable for this reason (structs/unions with references). // should be allowed, pure copy: struct S { int x; } const S s_const = {0}; S s_mutable = s_const; // currently not allowed On a related note, initialization of constant variables should be possible, even if the source value is constant: struct S1 { int x; } struct S2 { S1 s1; } const S1 s1_const = {0}; const S2 s2_const = {s1_const}; // currently not allowed
Comment #1 by bugzilla — 2008-03-07T00:23:35Z
Fixed dmd 2.012