digitalmars.D.bugs - [Issue 6260] New: [Memory Corruption] Passed around lazy arguments don't work with closures
- d-bugmail puremagic.com (42/42) Jul 06 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6260
- d-bugmail puremagic.com (11/11) Dec 28 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6260
http://d.puremagic.com/issues/show_bug.cgi?id=6260 Summary: [Memory Corruption] Passed around lazy arguments don't work with closures Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: timon.gehr gmx.ch --- Comment #0 from timon.gehr gmx.ch 2011-07-06 13:29:26 PDT --- Tested in DMD 2.053: auto foo(lazy int x){return {return x;};} auto bar(lazy int x){return foo(x);} void main(){assert(foo(1)()==bar(1)());} // assertion failure Workaround: auto foo(lazy int x){return {return x;};} auto bar(lazy int x){return foo({return x;}());} // destroy purpose of 'lazy' void main(){assert(foo(1)()==bar(1)());} // pass Some funny stuff: import std.stdio; void main(){ auto x=bar(1); writeln(x()); } writes: <Garbage integer value> 0 Where does "0" come from? void main(){ writeln(bar(1)()); } writes: <Garbage integer value> Segmentation Fault -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 06 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6260 timon.gehr gmx.ch changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- Comment #1 from timon.gehr gmx.ch 2011-12-28 09:53:56 PST --- lazy arguments are implicitly scoped, so this is by design. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 28 2011