Thread overview | |||||
---|---|---|---|---|---|
|
June 08, 2011 with statement doesn't call struct destructor? | ||||
---|---|---|---|---|
| ||||
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 |
June 08, 2011 Re: with statement doesn't call struct destructor? | ||||
---|---|---|---|---|
| ||||
Posted in reply to simendsjo | 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
|
June 08, 2011 Re: with statement doesn't call struct destructor? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On 08.06.2011 23:14, Jonathan M Davis wrote: > 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 http://d.puremagic.com/issues/show_bug.cgi?id=6128 |
Copyright © 1999-2021 by the D Language Foundation