November 17, 2014
https://issues.dlang.org/show_bug.cgi?id=13740

          Issue ID: 13740
           Summary: CTFE fails ref foreach over range
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: CTFE, wrong-code
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody@puremagic.com
          Reporter: ag0aep6g@gmail.com

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());
}

--