[Issue 11382] Bad closure variable with scoped destruction

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 30 05:48:14 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=11382


Maxim Fomin <maxim at maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim at maxim-fomin.ru


--- Comment #2 from Maxim Fomin <maxim at maxim-fomin.ru> 2013-10-30 05:48:08 PDT ---
I think this may break some code but I am not sure about that. 

What is more important is that conclusion in relevant threads was just not to
place dtor invocation in the end of function scope because stack struct touched
by closure is essentially object residing in the heap, and structs allocated in
the heap typically have no dtor call (unless they are wrapped into class or
some trick is used). Your proposal to reject code comes from nowhere and it is
unnecessary restrictive and does not fit into current practice: allocating
structs via new is allowed.

I think right solution is those raised into the thread: just disable dtor
invocation in the end of the function scope. Probably some temporal warning
will be needed.

In any case, except of struct touched by closure scenario, there are additional
cases which should be fixed: nested function and nested structs.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list