2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.dg / expr / anew4.C
blob8999ffb53c6d7162f2b5f597d1697ea9c8e28953
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 struct B
8   B();
9   int n;
12 B::B()
14   n = 137;
18 struct D : public B
20   double x;
24 D* allocate(int n)
26   return new D[n]();
29 int main()
31   const int n = 17;
32   D* p = allocate(n);
33   for (int i = 0; i < n; ++i)
34     if (p[i].n != 137 || p[i].x != 0)
35       return 1;
36   return 0;