June 10, 2008 [Issue 2148] New: Incorrect local closure detection when closure is used as local alias parameter | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2148 Summary: Incorrect local closure detection when closure is used as local alias parameter Product: D Version: 2.013 Platform: PC OS/Version: Windows Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: brunodomedeiros+bugz@gmail.com Check the following code: --- --- import std.stdio; template foo(alias magicFn) { int foo() { return magicFn(); } } int delegate() myfunc() { int num = 2; int nestedFunc() { return num; }; //return &nestedFunc; return &foo!(nestedFunc); } void main(string[] args) { auto dg = myfunc(); writeln("Dg result:", dg()); // prints garbage } ---- ---- Running this will print garbage, because the compiler thinks nestedFunc is a local closure (a closure that does not escape the enclosing scope), and thus will not allocate num on the heap. -- |
January 26, 2013 [Issue 2148] Incorrect local closure detection when closure is used as local alias parameter | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2148 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATE --- Comment #1 from Don <clugdbug@yahoo.com.au> 2013-01-26 02:22:01 PST --- My patch for bug 1841 fixes this. *** This issue has been marked as a duplicate of issue 1841 *** -- 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