PR c++/86728 - C variadic generic lambda.
[official-gcc.git] / gcc / testsuite / g++.dg / expr / anew4.C
blob4ce1d8899f96b7f6a99916f0f523b229438b06d7
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>
6 #include <new>
7 #include <stdlib.h>
8 #include <string.h>
10 struct B
12   B();
13   int n;
16 B::B()
18   n = 137;
22 struct D : public B
24   double x;
28 D* allocate(int n)
30   void *p;
31   p = malloc(n * sizeof (D));
32   memset (p, 0xff, n * sizeof(D));
33   return new (p) D[n]();
36 int main()
38   const int n = 17;
39   D* p = allocate(n);
40   for (int i = 0; i < n; ++i)
41     if (p[i].n != 137 || p[i].x != 0)
42       abort ();
43   exit (0);