Bug 7658 – [CTFE] assignment to reference in foreach fails without error message

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-03-07T02:13:00Z
Last change time
2012-11-01T23:59:10Z
Keywords
CTFE, wrong-code
Assigned to
nobody
Creator
alexander.breckel

Comments

Comment #0 by alexander.breckel — 2012-03-07T02:13:42Z
string foo() { string[] children = ["0"]; foreach(ref child; children) child = "1"; return children[0]; } void main() { static assert(foo() == "0"); assert(foo() == "1"); }
Comment #1 by zan77137 — 2012-10-08T07:41:36Z
*** Issue 8773 has been marked as a duplicate of this issue. ***
Comment #2 by yebblies — 2012-11-01T23:59:10Z
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.