Other

digitalmars.D.bugs - Is this correct behavyor? (template tuples)

Given a template like this:
template foo(V...)
{
void foo()
{
foreach(i,V)
{
// "i" is not a const
}
}
}
use like this:
foo!(1,2,3,4,5)();
Inside the foreach "i" can't be used as a constant in some cases. The
work around I have used is to index into V.
template foo(V...)
{
void foo()
{
foreach(i,j,V)
{
const int k = V[i];
// "i" is not a const
}
}
}
However this causes DMD to actually copy the values onto the stack (I
took a look at the disassembly). This even happens with optimization on.
(This /might/ be considered a bug in and of it's self.)
I'm not sure if either of these is actually a bug, so I'm hoping someone
else will take a think on them.