Bug 14321 – Unnecessary destructor call with and AA's

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-03-23T11:03:00Z
Last change time
2015-06-17T21:02:49Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
rswhite4

Comments

Comment #0 by rswhite4 — 2015-03-23T11:03:04Z
Code: ---- import std.stdio; struct Foo { this(int id) { writeln("CTor"); } this(this) { writeln("Postblit"); } ~this() { writeln("DTor"); } } void main() { Foo[string] foos; foos["test"] = Foo(42); writeln("end of main"); } ---- Expected behaviour ---- CTor end of main ---- or ---- CTor Postblit DTor end of main ---- But currently: ---- CTor DTor end of main ---- That ruins all interaction between AA's and ref counted structs.
Comment #1 by rswhite4 — 2015-03-23T11:05:08Z
Forget to mention, my compiler is DMD v2.067.0-rc1
Comment #2 by rswhite4 — 2015-03-23T11:07:33Z
(In reply to rswhite4 from comment #1) > Forget to mention, my compiler is DMD v2.067.0-rc1 Seems to produce an ICE in 2.065: http://dpaste.dzfl.pl/362689545fb6
Comment #3 by k.hara.pg — 2015-03-24T12:13:31Z
When an AA entry is newly created and initialized by the rvalue rhs, the value will be moved in the allocated slot. So the expected behavior is: > ---- > CTor > end of main > ---- https://github.com/D-Programming-Language/dmd/pull/4512
Comment #4 by github-bugzilla — 2015-03-25T08:51:45Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/751155f005db896546909e738ad4b576b17078d7 fix Issue 14321 - Unnecessary destructor call with and AA's https://github.com/D-Programming-Language/dmd/commit/48086f7479f0e1101c490ba8e3f33fc932da962f Merge pull request #4512 from 9rnsr/fix14321 Issue 14321 - Unnecessary destructor call with and AA's
Comment #5 by k.hara.pg — 2015-06-01T12:24:28Z
*** Issue 14595 has been marked as a duplicate of this issue. ***
Comment #6 by github-bugzilla — 2015-06-17T21:02:49Z