aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/expr/anew2.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/expr/anew2.C')
-rw-r--r--gcc/testsuite/g++.dg/expr/anew2.C20
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/expr/anew2.C b/gcc/testsuite/g++.dg/expr/anew2.C
new file mode 100644
index 00000000000..b8681897577
--- /dev/null
+++ b/gcc/testsuite/g++.dg/expr/anew2.C
@@ -0,0 +1,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>
+
+
+double* allocate(int n)
+{
+ return new double[n]();
+}
+
+int main()
+{
+ const int n = 17;
+ double* p = allocate(n);
+ for (int i = 0; i < n; ++i)
+ if (p[i] != 0.0)
+ return 1;
+ return 0;
+}