[Issue 1801] New: Const structs should be assignable to non-const variables unless they contain references
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jan 23 03:09:56 PST 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1801
Summary: Const structs should be assignable to non-const
variables unless they contain references
Product: D
Version: 2.010
Platform: PC
OS/Version: All
Status: NEW
Keywords: rejects-valid, spec
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: ludwig at informatik.uni-luebeck.de
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
--
More information about the Digitalmars-d-bugs
mailing list