http://d.puremagic.com/issues/show_bug.cgi?id=2564

           Summary: CTFE: the index in a tuple foreach is uninitialized
                    (bogus error)
           Product: D
           Version: 2.023
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzi...@digitalmars.com
        ReportedBy: clugd...@yahoo.com.au


int foo(E...)(string[2] s)
{
    foreach(int i,T; E) {
        auto z = s[i].dup;
    }
    return 0;
}

static x = foo!(int, int)(["x", "y"]);
---
bug.d(4): Error: variable i is used before initialization
bug.d(9): Error: cannot evaluate foo(&["x","y"]) at compile ti
me
bug.d(9): Error: cannot evaluate foo(&["x","y"]) at compile ti
me
---
A workaround:
    foreach(int j,T; E) {
       int i=j;
       ...
    }
Does not happen in D1.039


-- 

Reply via email to