with statement doesn't call struct destructor?

simendsjo simen.endsjo at pandavre.com
Wed Jun 8 14:21:13 PDT 2011


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


More information about the Digitalmars-d-learn mailing list