www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13044] New: Assignment of structs with const members


          Issue ID: 13044
           Summary: Assignment of structs with const members
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: stanislav.blinov gmail.com

DMD 2.065, 2.066b1

If a struct has a const member and a dtor defined, instances of that struct can
be assigned.

unittest {

struct Good { 
    const int i; 

struct Bad { 
    const int i;
    ~this() {}

Good good1, good2;
static assert(!__traits(compiles, { good1 = good2; }); // passes

Bad bad1, bad2;
static assert(!__traits(compiles, { bad1 = bad2; }); // fails


Jul 04 2014