Delegate is left with a destroyed stack object

Maxim Fomin maxim at maxim-fomin.ru
Wed Oct 30 23:19:48 PDT 2013


On Thursday, 31 October 2013 at 00:46:05 UTC, Xiaoxi wrote:
> On Wednesday, 30 October 2013 at 21:15:37 UTC, Ali Çehreli 
> wrote:
>> On 10/29/2013 10:55 AM, Ali Çehreli wrote:
>>
>> > Continuing the conversation from the following thread:
>> >
>> >   http://forum.dlang.org/post/l4mi8l$1r1$1@digitalmars.com
>>
>> Kenji Hara added there:
>>
>> =====
>> The combination of closure variables + scoped destruction 
>> should
>> be rejected, but currently it isn't. It's a compiler bug.
>>
>> http://d.puremagic.com/issues/show_bug.cgi?id=11382
>>
>> Kenji Hara
>> =====
>>
>> Ali
>
> kenji is right. compilation error is the only safe approach, if 
> you do not wish scoped destruction, don’t request it in the 
> first place! dangerous operations like this should be explicit 
> to avoid surprises, not hidden in complicared implicit special 
> cases.

This is wrong in a point that accessing object or not running 
destructor is not safe: closures can touch any object, not only 
structs, making them allocated in heap, and there are many cases 
when struct destructors are not called.


More information about the Digitalmars-d mailing list