Bug 9993 – const ctor should be preferred than mutable for const obj creation
Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-04-25T23:56:00Z
Last change time
2013-04-28T18:48:00Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2013-04-25T23:56:29Z
This code should work, but currently fails at the last assertion in runtime.
class B
{
int x;
this() const { x = 42; }
this() { x = 13; }
}
void main()
{
const B mb = new B;
assert(mb.x == 13);
const B cb = new const B;
assert(cb.x == 42); // fails!
}