PR tree-optimization/84740
[official-gcc.git] / gcc / testsuite / gcc.dg / pr30286.c
blobd35eacd807a9b2246bb06756ae7541cb808b404b
1 /* PR middle-end/30286 */
2 /* { dg-do run } */
3 /* { dg-options "-O2 -ftrapv" } */
4 /* { dg-require-effective-target trapping } */
6 extern void abort (void);
7 struct S { struct S *s; };
8 struct T { struct S *t[25]; };
10 void
11 __attribute__((noinline))
12 foo (int i, struct T *x, struct S *y)
14 int j;
15 for (j = 14; j > i; j--)
16 x->t[j] = y->s;
19 int
20 main (void)
22 struct S s;
23 struct T t;
24 int i;
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;