Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
August 02, 2012 [Issue 8498] New: inconsistent foreach behaviour in CTFE and at runtime | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=8498 Summary: inconsistent foreach behaviour in CTFE and at runtime Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: regression Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: timon.gehr@gmx.ch --- Comment #0 from timon.gehr@gmx.ch 2012-08-02 13:54:00 PDT --- Passes with DMD 2.059, asserts with DMD 2.060: int fun(){ int r; foreach(i;0..10) r+=i++; return r; } enum x = fun(); void main(){ assert(fun()==x); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 03, 2012 [Issue 8498] modifying foreach range iterator fails in CTFE | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=8498 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |CTFE, wrong-code CC| |clugdbug@yahoo.com.au Summary|inconsistent foreach |modifying foreach range |behaviour in CTFE and at |iterator fails in CTFE |runtime | --- Comment #1 from Don <clugdbug@yahoo.com.au> 2012-09-03 00:52:40 PDT --- Here's a reduced test case. There are 10 iterations, even though the iteration variable is changed. int fun(){ int r=0; foreach(i;0..10) { ++r; i= 100; assert(i==100); // ok -- but doesn't affect the foreach } return r; } static assert(fun() == 1); Interestingly this is in direct conflict with enhancement bug 6214, which asks for the behaviour we see in CTFE to be used at run time. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 03, 2012 [Issue 8498] modifying foreach range iterator fails in CTFE | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=8498 --- Comment #2 from timon.gehr@gmx.ch 2012-09-03 08:09:07 PDT --- (In reply to comment #1) > Here's a reduced test case. There are 10 iterations, even though the iteration variable is changed. > > int fun(){ > int r=0; > foreach(i;0..10) { > ++r; > i= 100; > assert(i==100); // ok -- but doesn't affect the foreach > } > return r; > } > static assert(fun() == 1); > > > Interestingly this is in direct conflict with enhancement bug 6214, which asks for the behaviour we see in CTFE to be used at run time. Interestingly the original bug report/title wasn't as it explicitly took this into account. :o) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 03, 2012 [Issue 8498] modifying foreach range iterator fails in CTFE | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=8498 timon.gehr@gmx.ch changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |philippe.sigaud@gmail.com --- Comment #3 from timon.gehr@gmx.ch 2012-09-03 11:06:18 PDT --- *** Issue 8614 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: ------- |
November 02, 2012 [Issue 8498] modifying foreach range iterator fails in CTFE | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=8498 --- Comment #4 from github-bugzilla@puremagic.com 2012-11-01 23:49:34 PDT --- Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/b52dca5a53def60352dbcbf4f398c10abb2cb6b1 Fix issue 8498 modifying foreach range iterator fails in CTFE This was caused by ignoring assignment to ref variables. (These guys can only be created by the inliner, or by lowering, such as happens in foreach). Also fixes bug 7658: assignment to ref in foreach. Also fixes bug 8539: nested functions, ref parameter, -inline. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 02, 2012 [Issue 8498] modifying foreach range iterator fails in CTFE | ||||
---|---|---|---|---|
| ||||
Posted in reply to timon.gehr@gmx.ch | http://d.puremagic.com/issues/show_bug.cgi?id=8498 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies@gmail.com Resolution| |FIXED -- 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