| 1 |
/* PERMUTE_ARGS: -O |
| 2 |
*/ |
| 3 |
|
| 4 |
// https://issues.dlang.org/show_bug.cgi?id=22104 |
| 5 |
|
| 6 |
struct S { int a1, a2, a3; } |
| 7 |
|
| 8 |
version (none) |
| 9 |
void throws2ndCall(ref S x); |
| 10 |
else |
| 11 |
{ |
| 12 |
void throws2ndCall(ref S x) |
| 13 |
{ |
| 14 |
__gshared bool b; |
| 15 |
if (b) |
| 16 |
throw new Exception("n == 1"); |
| 17 |
b = true; |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
void main() { foo(); } |
| 22 |
|
| 23 |
void foo() |
| 24 |
{ |
| 25 |
S[] arr = [S(), S()]; |
| 26 |
size_t i; |
| 27 |
try |
| 28 |
{ |
| 29 |
for (i = 0; i < 2; i++) |
| 30 |
throws2ndCall(arr[i]); |
| 31 |
} |
| 32 |
catch (Exception o) |
| 33 |
{ |
| 34 |
//printf("Exception: i = %lu\n", i); |
| 35 |
assert(i == 1); // this fails |
| 36 |
} |
| 37 |
} |