digitalmars.D.learn - with statement doesn't call struct destructor?
- simendsjo (20/20) Jun 08 2011 import std.stdio;
- Jonathan M Davis (7/31) Jun 08 2011 Report it on bugzilla. Walter has been fixing issues with destructors fo...
- simendsjo (2/33) Jun 08 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6128
import std.stdio; void main() { struct S { this(bool a) { writeln(" this"); } ~this() { writeln(" ~this"); } } writeln("scoped:"); { auto s = S(true); } writeln("with:"); with(S(true)) { } } Output: scoped: this ~this with: this
Jun 08 2011
On 2011-06-08 13:31, simendsjo wrote:import std.stdio; void main() { struct S { this(bool a) { writeln(" this"); } ~this() { writeln(" ~this"); } } writeln("scoped:"); { auto s = S(true); } writeln("with:"); with(S(true)) { } } Output: scoped: this ~this with: thisReport it on bugzilla. Walter has been fixing issues with destructors for temporaries lately. They've been buggy for a while. A fair bit of the problem was fixed in dmd 2.053 but not all of it. If you're not using 2.053, then that's probably why the code is broken. If you are using 2.053, then Walter needs to be aware that that particular use case hasn't been fixed yet. - Jonathan M Davis
Jun 08 2011
On 08.06.2011 23:14, Jonathan M Davis wrote:On 2011-06-08 13:31, simendsjo wrote:http://d.puremagic.com/issues/show_bug.cgi?id=6128import std.stdio; void main() { struct S { this(bool a) { writeln(" this"); } ~this() { writeln(" ~this"); } } writeln("scoped:"); { auto s = S(true); } writeln("with:"); with(S(true)) { } } Output: scoped: this ~this with: thisReport it on bugzilla. Walter has been fixing issues with destructors for temporaries lately. They've been buggy for a while. A fair bit of the problem was fixed in dmd 2.053 but not all of it. If you're not using 2.053, then that's probably why the code is broken. If you are using 2.053, then Walter needs to be aware that that particular use case hasn't been fixed yet. - Jonathan M Davis
Jun 08 2011