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

     1  struct VEC_char_base
     2  {
     3    unsigned num;
     4    unsigned alloc;
     5    union {
     6        short vec[1];
     7        struct {
     8  	  int i;
     9  	  int j;
    10  	  int k;
    11        } a;
    12    } u;
    13  };
    14  
    15  short __attribute__((noinline))
    16  foo (struct VEC_char_base *p, int i)
    17  {
    18    short *q;
    19    p->u.vec[i] = 0;
    20    q = &p->u.vec[16];
    21    *q = 1;
    22    return p->u.vec[i];
    23  }
    24  
    25  extern void abort (void);
    26  extern void *malloc (__SIZE_TYPE__);
    27  
    28  int
    29  main()
    30  {
    31    struct VEC_char_base *p = malloc (sizeof (struct VEC_char_base) + 256);
    32    if (foo (p, 16) != 1)
    33      abort ();
    34    return 0;
    35  }