[Issue 2564] New: CTFE: the index in a tuple foreach is uninitialized (bogus error)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jan 7 12:05:33 PST 2009
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: bugzilla at digitalmars.com
ReportedBy: clugdbug at 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
--
More information about the Digitalmars-d-bugs
mailing list