int main()
{
array(int) positions=({4,3});
int pos=1;
array unrolled=({});
foreach (positions, int nextpos)
{
write("Extending to %d\n",nextpos);
for (;pos<=nextpos;++pos) unrolled+=({"Spam"});
}
}
The basic concept is that it should unroll an array of counts into
individual entries. (Think run-length decoding or something.) There's
a bug in it, that the second position is lower than the first. A naive
implementation would simply note that pos isn't less than or equal to
nextpos, ergo it should skip the loop altogether; and in Pike 7.8.352,
this is what happens. In Pike 8.1 current, this results in an infinite
loop that allocates gobs of memory.
I tried to bisect to find the problem, but it's been there for a very
long time, and a lot of the old builds won't compile on my system for
some reason.
ChrisA