Bug 13044 – Assignment of structs with const members
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-07-04T16:27:00Z
Last change time
2014-08-22T08:04:13Z
Keywords
accepts-invalid, pull
Assigned to
nobody
Creator
stanislav.blinov
Comments
Comment #0 by stanislav.blinov — 2014-07-04T16:27:08Z
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
}