http://d.puremagic.com/issues/show_bug.cgi?id=8614
Summary: Cannot change the iteration index during CTFE Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: philippe.sig...@gmail.com --- Comment #0 from Philippe Sigaud <philippe.sig...@gmail.com> 2012-09-03 19:22:36 CEST --- During runtime execution of a foreach loop, you can change the index. This doesn't work at compile-time and gives a different result when foo is called through CTFE or at runtime: import std.stdio; int[] foo(int[] data) { foreach (i, ref x; data) { x++; i++; } return data; } void main() { // Compile-time enum result1 = foo([10, 20, 30, 40]); assert(result1 == [11, 21, 31, 41]); // Runtime auto result2 = foo([10, 20, 30, 40]); assert(result2 == [11, 20, 31, 40]); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------