http://d.puremagic.com/issues/show_bug.cgi?id=8621
Summary: Iterattion variable in foreach not closed upon
properly in delegate
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: [email protected]
ReportedBy: [email protected]
--- Comment #0 from Andrei Alexandrescu <[email protected]> 2012-09-05
02:49:47 PDT ---
Consider:
import std.stdio;
void main() {
void delegate()[] a;
foreach (i; 1 .. 10) {
a ~= { writeln(i); };
}
foreach (f; a) {
f();
}
}
This program prints an arbitrary value every run, which means i is not properly
closed upon.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------