This commit was manufactured by cvs2svn to create branch
[official-gcc.git] / gcc / testsuite / g++.dg / expr / anew1.C
blob9e0d0ec601f9512c50426152307fc9c6cb9243f1
1 // { dg-do run { xfail *-*-* } }
2 // XFAILed until PR2123 is fixed
3 // PR 11228: array operator new, with zero-initialization and a variable sized array.
4 // Regression test for PR 
5 // Author: Matt Austern <austern@apple.com>
8 #include <new>
9 #include <stdlib.h>
10 #include <string.h>
12 int* allocate(int n)
14   void *p;
15   p = malloc(n * sizeof (int));
16   memset (p, 0xff, n * sizeof(int));
17   return new (p) int[n]();
20 int main()
22   const int n = 17;
23   int* p = allocate(n);
24   for (int i = 0; i < n; ++i)
25     if (p[i] != 0)
26       abort ();
27   exit (0);