| 1 |
/* { dg-add-options stack_size } */ |
| 2 |
|
| 3 |
#include <stdlib.h> |
| 4 |
|
| 5 |
int *a, *b; |
| 6 |
int n; |
| 7 |
|
| 8 |
#ifdef STACK_SIZE |
| 9 |
#define BLOCK_SIZE (STACK_SIZE / (sizeof (*a) + sizeof (*b))) |
| 10 |
#else |
| 11 |
#define BLOCK_SIZE 32768 |
| 12 |
#endif |
| 13 |
void |
| 14 |
foo (void) |
| 15 |
{ |
| 16 |
int i; |
| 17 |
for (i = 0; i < n; i++) |
| 18 |
a[i] = -1; |
| 19 |
for (i = 0; i < BLOCK_SIZE - 1; i++) |
| 20 |
b[i] = -1; |
| 21 |
} |
| 22 |
|
| 23 |
int |
| 24 |
main (void) |
| 25 |
{ |
| 26 |
n = BLOCK_SIZE; |
| 27 |
a = malloc (n * sizeof(*a)); |
| 28 |
b = malloc (n * sizeof(*b)); |
| 29 |
*b++ = 0; |
| 30 |
foo (); |
| 31 |
if (b[-1]) |
| 32 |
abort (); |
| 33 |
exit (0); |
| 34 |
} |