Merge -r 127928:132243 from trunk
[official-gcc.git] / gcc / testsuite / g++.dg / init / new26.C
blob541de3058e10a09057c4effd5004efbca780d673
1 // PR c++/33407
2 // { dg-do run }
3 // { dg-options "-O2 -fstrict-aliasing" }
5 extern "C" void * malloc(__SIZE_TYPE__);
6 extern "C" void abort(void);
8 void *p;
9 void __attribute__((noinline)) init(void)
11   p = malloc(4);
14 inline void *operator new(__SIZE_TYPE__)
16   return p;
19 inline void operator delete (void*) {}
21 int * __attribute__((noinline)) doit(int n)
23   float *q;
24   int *r;
26   for (int i=0; i<n; ++i)
27   {
28     q = new float;
29     *q = 1.0;
30     delete q;
31     r = new int;
32     *r = 1;
33   }
35   return r;
38 int main()
40   init();
41   if (*doit(1) != 1)
42     abort();
43   return 0;