www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1801] New: Const structs should be assignable to non-const variables unless they contain references

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: ludwig 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


-- 
Jan 23 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1801


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





Fixed dmd 2.012


-- 
Mar 06 2008