digitalmars.D.bugs - [Issue 8614] New: Cannot change the iteration index during CTFE
- d-bugmail puremagic.com (37/37) Sep 03 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8614
- d-bugmail puremagic.com (12/12) Sep 03 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8614
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: nobody puremagic.com ReportedBy: philippe.sigaud gmail.com --- Comment #0 from Philippe Sigaud <philippe.sigaud 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: -------
Sep 03 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8614 timon.gehr gmx.ch changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |timon.gehr gmx.ch Resolution| |DUPLICATE --- Comment #1 from timon.gehr gmx.ch 2012-09-03 11:06:18 PDT --- *** This issue has been marked as a duplicate of issue 8498 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 03 2012