(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
torture/
pr60183.c
       1  /* { dg-do run } */
       2  /* { dg-require-effective-target size32plus } */
       3  
       4  /* Large so an out-of-bound read will crash.  */
       5  unsigned char c[0x30001] = { 1 };
       6  int j = 2;
       7  
       8  static void
       9  foo (unsigned long *x, unsigned char *y)
      10  {
      11    int i;
      12    unsigned long w = x[0];
      13    for (i = 0; i < j; i++)
      14      {
      15        w += *y;
      16        y += 0x10000;
      17        w += *y;
      18        y += 0x10000;
      19      }
      20    x[1] = w;
      21  }
      22  
      23  __attribute__ ((noinline, noclone)) void
      24  bar (unsigned long *x)
      25  {
      26    foo (x, c);
      27  }
      28  
      29  int
      30  main ()
      31  {
      32    unsigned long a[2] = { 0, -1UL };
      33    asm volatile (""::"r" (c):"memory");
      34    c[0] = 0;
      35    bar (a);
      36    if (a[1] != 0)
      37      __builtin_abort ();
      38    return 0;
      39  }