xxxxxxxxxx
import std.stdio : printf;
static size_t n;
void throws2ndCall(T)(ref T x)
{
if (n == 1)
throw new Exception("n == 1");
++n;
}
void foo(T)(scope T[] arr)
{
size_t i;
try
{
for (i = 0; i < arr.length; i++)
throws2ndCall(arr[i]);
}
catch (Exception o)
{
printf("Exception: i = %lu; n = %lu\n", i, n); // prints 0 and 1
assert(i == n); // this fails
}
}
void main()
{
static struct S { int a1, a2, a3, a4, a5; }
// foo([S(), S()]);
}