[Issue 13044] New: Assignment of structs with const members

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jul 4 09:27:08 PDT 2014


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: nobody at puremagic.com
          Reporter: stanislav.blinov at 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

}

--


More information about the Digitalmars-d-bugs mailing list