modernc.org/ccgo/v3@v3.16.14/lib/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/execute/960521-1.c (about)

     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  foo ()
    14  {
    15    int i;
    16    for (i = 0; i < n; i++)
    17      a[i] = -1;
    18    for (i = 0; i < BLOCK_SIZE - 1; i++)
    19      b[i] = -1;
    20  }
    21  
    22  main ()
    23  {
    24    n = BLOCK_SIZE;
    25    a = malloc (n * sizeof(*a));
    26    b = malloc (n * sizeof(*b));
    27    *b++ = 0;
    28    foo ();
    29    if (b[-1])
    30      abort ();
    31    exit (0);
    32  }