LWG 3035. std::allocator's constructors should be constexpr
[official-gcc.git] / gcc / testsuite / gcc.dg / pr84503-1.c
blob03fb2fbd9a522c7c11da7d2dcad60d6484e36c89
1 /* PR tree-optimization/84503 */
2 /* { dg-do run } */
3 /* { dg-options "-O3" } */
5 typedef __SIZE_TYPE__ size_t;
6 typedef __UINTPTR_TYPE__ uintptr_t;
8 struct S { int a; unsigned short b; int c, d, e; long f, g, h; int i, j; };
9 static struct S *k;
10 static size_t l = 0;
11 int m;
13 static int
14 bar (void)
16 unsigned i;
17 int j;
18 if (k[0].c == 0)
20 ++m;
21 size_t n = l * 2;
22 struct S *o;
23 o = (struct S *) __builtin_realloc (k, sizeof (struct S) * n);
24 if (!o)
25 __builtin_exit (0);
26 k = o;
27 for (i = l; i < n; i++)
29 void *p = (void *) &k[i];
30 int q = 0;
31 size_t r = sizeof (struct S);
32 if ((((uintptr_t) p) % __alignof__ (long)) == 0
33 && r % sizeof (long) == 0)
35 long __attribute__ ((may_alias)) *s = (long *) p;
36 long *t = (long *) ((char *) s + r);
37 while (s < t)
38 *s++ = 0;
40 else
41 __builtin_memset (p, q, r);
42 k[i].c = i + 1;
43 k[i].a = -1;
45 k[n - 1].c = 0;
46 k[0].c = l;
47 l = n;
49 j = k[0].c;
50 k[0].c = k[j].c;
51 return j;
54 int
55 main ()
57 k = (struct S *) __builtin_malloc (sizeof (struct S));
58 if (!k)
59 __builtin_exit (0);
60 __builtin_memset (k, '\0', sizeof (struct S));
61 k->a = -1;
62 l = 1;
63 for (int i = 0; i < 15; ++i)
64 bar ();
65 if (m != 4)
66 __builtin_abort ();
67 return 0;