with statement doesn't call struct destructor?
Jonathan M Davis
jmdavisProg at gmx.com
Wed Jun 8 14:14:18 PDT 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:
> this
Report 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
More information about the Digitalmars-d-learn
mailing list