(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
pr30286.c
       1  /* PR middle-end/30286 */
       2  /* { dg-do run } */
       3  /* { dg-options "-O2 -ftrapv" } */
       4  /* { dg-require-effective-target trapping } */
       5  
       6  extern void abort (void);
       7  struct S { struct S *s; };
       8  struct T { struct S *t[25]; };
       9  
      10  void
      11  __attribute__((noinline))
      12  foo (int i, struct T *x, struct S *y)
      13  {
      14    int j;
      15    for (j = 14; j > i; j--)
      16      x->t[j] = y->s;
      17  }
      18  
      19  int
      20  main (void)
      21  {
      22    struct S s;
      23    struct T t;
      24    int i;
      25  
      26    s.s = &s;
      27    __builtin_memset (&t, 0, sizeof (t));
      28    foo (6, &t, &s);
      29    for (i = 0; i < 25; i++)
      30      if (t.t[i] != ((i > 6 && i <= 14) ? &s : (struct S *) 0))
      31        abort ();
      32    __builtin_memset (&t, 0, sizeof (t));
      33    foo (-1, &t, &s);
      34    for (i = 0; i < 25; i++)
      35      if (t.t[i] != ((i >= 0 && i <= 14) ? &s : (struct S *) 0))
      36        abort ();
      37    return 0;
      38  }