https://issues.dlang.org/show_bug.cgi?id=13044

          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: [email protected]
          Reporter: [email protected]

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

}

--

Reply via email to