aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/expr/anew1.C
blob: a14408ace0ab23b2f2197cb5c010d3f458c9be8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// { dg-do run }
// PR 11228: array operator new, with zero-initialization and a variable sized array.
// Regression test for PR 
// Author: Matt Austern <austern@apple.com>


int* allocate(int n)
{
  return new int[n]();
}

int main()
{
  const int n = 17;
  int* p = allocate(n);
  for (int i = 0; i < n; ++i)
    if (p[i] != 0)
      return 1;
  return 0;
}