Dead
[official-gcc.git] / gomp-20050608-branch / gcc / testsuite / g++.dg / expr / anew1.C
blobd7a4288802a10f1b8ee7f810c194c86df5af9274
1 // { dg-do run }
2 // PR 11228: array operator new, with zero-initialization and a variable sized array.
3 // Regression test for PR 
4 // Author: Matt Austern <austern@apple.com>
7 #include <new>
8 #include <stdlib.h>
9 #include <string.h>
11 int* allocate(int n)
13   void *p;
14   p = malloc(n * sizeof (int));
15   memset (p, 0xff, n * sizeof(int));
16   return new (p) int[n]();
19 int main()
21   const int n = 17;
22   int* p = allocate(n);
23   for (int i = 0; i < n; ++i)
24     if (p[i] != 0)
25       abort ();
26   exit (0);