| 1 |
/* |
| 2 |
PERMUTE_ARGS: |
| 3 |
RUN_OUTPUT: |
| 4 |
--- |
| 5 |
Success |
| 6 |
--- |
| 7 |
*/ |
| 8 |
|
| 9 |
module testgc2; |
| 10 |
|
| 11 |
import core.stdc.stdio; |
| 12 |
import core.exception : OutOfMemoryError; |
| 13 |
|
| 14 |
/*******************************************/ |
| 15 |
|
| 16 |
__gshared ulong counter; |
| 17 |
|
| 18 |
void test1() |
| 19 |
{ |
| 20 |
try |
| 21 |
{ |
| 22 |
long[] l = new long[ptrdiff_t.max]; |
| 23 |
counter += l.capacity; // Make sure l is not optimized out. |
| 24 |
assert(0); |
| 25 |
} |
| 26 |
catch (OutOfMemoryError o) |
| 27 |
{ |
| 28 |
} |
| 29 |
|
| 30 |
assert(counter == 0); |
| 31 |
|
| 32 |
try |
| 33 |
{ |
| 34 |
byte[] b = new byte[size_t.max / 3]; |
| 35 |
counter += b.capacity; // Make sure b is not optimized out. |
| 36 |
version (Windows) |
| 37 |
assert(0); |
| 38 |
} |
| 39 |
catch (OutOfMemoryError o) |
| 40 |
{ |
| 41 |
} |
| 42 |
|
| 43 |
assert(counter >= 0); |
| 44 |
} |
| 45 |
|
| 46 |
/*******************************************/ |
| 47 |
|
| 48 |
void main() |
| 49 |
{ |
| 50 |
test1(); |
| 51 |
|
| 52 |
printf("Success\n"); |
| 53 |
} |