Bug 13740 – CTFE fails ref foreach over range

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-11-17T01:52:00Z
Last change time
2015-02-18T03:42:30Z
Keywords
CTFE, pull, wrong-code
Assigned to
nobody
Creator
ag0aep6g

Comments

Comment #0 by ag0aep6g — 2014-11-17T01:52:59Z
class R { int e; bool empty = false; @property ref front() {return e;} void popFront() {empty = true;} } bool test() { auto r = new R; foreach(ref e; r) e = 42; assert(r.e == 42); /* fails in CTFE */ return true; } void main() { version(rt) assert(test()); version(ct) static assert(test()); }
Comment #1 by k.hara.pg — 2015-01-01T14:58:41Z
Comment #2 by github-bugzilla — 2015-01-14T07:12:38Z
Comment #3 by github-bugzilla — 2015-02-18T03:42:30Z