I found the particularly nasty example where introducing a non scoped delegate breaks the preceding loop with DMD 2.060.
-------------
module t6;
import core.stdc.stdio;
void ff(T)(T[] arr1){
T[] copyArr=new T[](arr1.length);
size_t ii=0;
foreach(size_t i,T e;arr1){
// i is invalid, accessing did segfaults in the original bug
// changing the delegate below (to remove code dep) it is now "only" invalid
printf("i=%ld\n",i);
scope dl=delegate void(int sink){
if (i>10)
assert(0);
};
}
ii=0;
// using a scoped delegate here removes the bug
auto dlg=delegate bool(ref T*el){
if (ii<1){ // originally also ++ii;
return true;
}
return false;
};
}
int main(string[]args){
int[]narr=new int[](3);
ff(narr);
return 0;
}
----------
Comment #1 by k.hara.pg — 2012-11-08T21:15:15Z
*** This issue has been marked as a duplicate of issue 8526 ***