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! }
Comment #1 by k.hara.pg — 2013-04-26T00:11:19Z
https://github.com/D-Programming-Language/dmd/pull/1939 This is a blocker issue for 2.063 release.
Comment #2 by github-bugzilla — 2013-04-26T14:46:06Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/1dbcc7c9922480b208f3cf91aa286ea233f2d18b fix Issue 9993 - const ctor should be preferred than mutable for const obj creation https://github.com/D-Programming-Language/dmd/commit/2de30b3cd95c6e59e2acc90d72adb1b1c8a99afc Merge pull request #1939 from 9rnsr/fix9993 Issue 9993 - const ctor should be preferred than mutable for const obj creation