Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
February 26, 2011 [Issue 5655] New: Lambda inside static foreach saves wrong value of counter | ||||
---|---|---|---|---|
| ||||
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 --- Comment #0 from Andrei Alexandrescu <andrei@metalanguage.com> 2011-02-26 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: ------- |
April 22, 2012 [Issue 5655] Lambda inside static foreach saves wrong value of counter | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=5655 SomeDude <lovelydear@mailmetrash.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |lovelydear@mailmetrash.com --- Comment #1 from SomeDude <lovelydear@mailmetrash.com> 2012-04-22 16:53:08 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: ------- |
July 08, 2012 [Issue 5655] Lambda inside static foreach saves wrong value of counter | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=5655 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |wfunction@hotmail.com --- Comment #2 from yebblies <yebblies@gmail.com> 2012-07-08 22:13:17 EST --- *** 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: ------- |
July 17, 2012 [Issue 5655] Lambda inside static foreach saves wrong value of counter | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=5655 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |siegelords_abode@yahoo.com --- Comment #3 from yebblies <yebblies@gmail.com> 2012-07-18 03:56:55 EST --- *** 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: ------- |
March 07, 2013 [Issue 5655] Lambda inside static foreach saves wrong value of counter | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | http://d.puremagic.com/issues/show_bug.cgi?id=5655 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #4 from bearophile_hugs@eml.cc 2013-03-06 16:16:46 PST --- Related to Issue 9628 ? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 19, 2013 [Issue 5655] Lambda inside static foreach saves wrong value of counter | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | 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 --- Comment #5 from hsteoh@quickfur.ath.cx 2013-08-18 22:34:55 PDT --- 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: ------- |
Copyright © 1999-2021 by the D Language Foundation