Thread overview | ||||||
---|---|---|---|---|---|---|
|
October 30, 2013 [Issue 11382] New: Bad closure variable with scoped destruction | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=11382 Summary: Bad closure variable with scoped destruction Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: accepts-invalid Severity: critical Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: k.hara.pg@gmail.com --- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2013-10-29 21:32:40 PDT --- In the following code, compiler should reject the function 'foo' by "has scoped destruction, cannot build closure" error. struct S { ~this() {} } auto foo() { S s = S(); return { s = S(); }; } void main() {} It is checked in toir.c FuncDeclaration::buildClosure(), however currently it doesn't work for the variables which are explicitly declared on statement. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 30, 2013 [Issue 11382] Bad closure variable with scoped destruction | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=11382 --- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2013-10-29 21:33:06 PDT --- Related discussion: http://forum.dlang.org/thread/wsketyuhrbwiaetfbfww@forum.dlang.org -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 30, 2013 [Issue 11382] Bad closure variable with scoped destruction | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=11382 Maxim Fomin <maxim@maxim-fomin.ru> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |maxim@maxim-fomin.ru --- Comment #2 from Maxim Fomin <maxim@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: ------- |
October 30, 2013 [Issue 11382] Bad closure variable with scoped destruction | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=11382 Ali Cehreli <acehreli@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |acehreli@yahoo.com --- Comment #3 from Ali Cehreli <acehreli@yahoo.com> 2013-10-30 14:16:37 PDT --- The rest of the discussion: http://forum.dlang.org/post/l4osr0$2f3q$1@digitalmars.com Ali -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation