digitalmars.D.bugs - [Issue 2341] New: Double destruction without intervening copy
- d-bugmail puremagic.com (44/44) Sep 06 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2341
- d-bugmail puremagic.com (11/11) Sep 08 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2341
- d-bugmail puremagic.com (5/16) Sep 08 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2341
- d-bugmail puremagic.com (9/9) Oct 20 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2341
http://d.puremagic.com/issues/show_bug.cgi?id=2341 Summary: Double destruction without intervening copy Product: D Version: unspecified Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: andrei metalanguage.com import std.stdio; struct A { int id; this(int x) { id = x; writeln("Created object from scratch: ", x); } this(this) { writeln("Copying object: ", id); } ~this() { writeln("Destroying object: ", id); } } struct B { A member; } B foo() { A a = A(45); return B(a); } void main() { auto b = foo; } The code above prints: Created object from scratch: 45 Destroying object: 45 Destroying object: 45 Obviously there should be an intervening copy, otherwise the same state gets destructed twice. The correct output should be: Created object from scratch: 45 Destroying object: 45 Copying object: 45 Destroying object: 45 --
Sep 06 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2341 Shouldn't the correct output be: Created object from scratch: 45 Copying object: 45 Destroying object: 45 Destroying object: 45 ? After all, the postblit in the "B(a)" expression must run before foo's scope ends and "a" is destroyed, right? --
Sep 08 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2341Shouldn't the correct output be: Created object from scratch: 45 Copying object: 45 Destroying object: 45 Destroying object: 45 ? After all, the postblit in the "B(a)" expression must run before foo's scope ends and "a" is destroyed, right?Correct, thank you. --
Sep 08 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2341 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED Fixed dmd 2.020 --
Oct 20 2008