digitalmars.D.bugs - [Issue 5655] New: Lambda inside static foreach saves wrong value of counter
- d-bugmail puremagic.com (30/30) Feb 26 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5655
- d-bugmail puremagic.com (24/24) Apr 22 2012 http://d.puremagic.com/issues/show_bug.cgi?id=5655
- d-bugmail puremagic.com (10/10) Jul 08 2012 http://d.puremagic.com/issues/show_bug.cgi?id=5655
- d-bugmail puremagic.com (10/10) Jul 17 2012 http://d.puremagic.com/issues/show_bug.cgi?id=5655
- d-bugmail puremagic.com (10/10) Mar 06 2013 http://d.puremagic.com/issues/show_bug.cgi?id=5655
- d-bugmail puremagic.com (31/31) Aug 18 2013 http://d.puremagic.com/issues/show_bug.cgi?id=5655
http://d.puremagic.com/issues/show_bug.cgi?id=5655 Summary: Lambda inside static foreach saves wrong value of counter Product: D Version: D2 Platform: Other OS/Version: Mac OS X Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: andrei metalanguage.com 09:25:07 PST --- This program should print 1 but instead prints 0. Apparently all lambdas inside a static foreach loop capture 0. import std.stdio, std.typetuple; void main() { TypeTuple!(int, float) TT; void function() funs[2]; foreach (i, T; TT) { funs[i] = function { writeln(i); }; } funs[1](); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 26 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5655 SomeDude <lovelydear mailmetrash.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lovelydear mailmetrash.com PDT --- Output on 2.059 Win32: PS E:\DigitalMars\dmd2\samples> rdmd bug.d OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html I:\DOCUME~1\Nick\LOCALS~1\Temp\.rdmd\rdmd-bug.d-E7282F21F02BD0DD07E8BB39480BDC77\bug-d-E7282F21F02BD0DD07E8BB39480BDC77.obj(bug-d-E7282F21F02BD0DD07E8BB39480BDC77) Offset 00DA9H Record Type 00C3 Error 1: Previous Definition Different : _D3bug4mainFZv14__funcliteral1FZv --- errorlevel 1 PS E:\DigitalMars\dmd2\samples> PS E:\DigitalMars\dmd2\samples> dmd -lib bug.d bug.lib: Error: multiple definition of bug_1_1a5: _D3bug4mainFZv14__funcliteral1FZv and bug_1_1a5: _D3bug4mainFZv14__funcliteral1FZv PS E:\DigitalMars\dmd2\samples> -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 22 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5655 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |wfunction hotmail.com *** Issue 8351 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 08 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5655 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |siegelords_abode yahoo.com *** Issue 7798 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 17 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5655 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc Related to Issue 9628 ? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 06 2013
http://d.puremagic.com/issues/show_bug.cgi?id=5655 hsteoh quickfur.ath.cx changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |hsteoh quickfur.ath.cx Resolution| |FIXED This bug appears to have been fixed in the latest git HEAD. To prove that it has really been fixed (not just have a different wrong value for i captured), I expanded the code slightly: ------ import std.stdio, std.typetuple; void main() { TypeTuple!(int, float, real) TT; void function() funs[3]; foreach (i, T; TT) { funs[i] = function { writeln(i); }; } funs[1](); funs[2](); } ------ The output is: 1 2 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 18 2013