diff options
author | austern <austern@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-06-20 00:33:58 +0000 |
---|---|---|
committer | austern <austern@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-06-20 00:33:58 +0000 |
commit | 6e7144d52ba646d610fb87c2fced67ac3a7d7a5f (patch) | |
tree | 179855e458e087c8af77e7b247e9693d89ff9b45 /gcc/testsuite | |
parent | 8eebd916f60b5b1233739ea94eae9fa644a94ae7 (diff) | |
download | gcc-6e7144d52ba646d610fb87c2fced67ac3a7d7a5f.tar.gz |
Fix for PR c++/11228, infinite loop for new int[n]().
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@68235 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/expr/anew1.C | 20 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/expr/anew2.C | 20 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/expr/anew3.C | 25 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/expr/anew4.C | 37 |
5 files changed, 110 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4c848dda2dc..2a1363af422 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2003-06-19 Matt Austern <austern@apple.com> + + PR c++/11228 + * g++.dg/anew1.C: New test. + * g++.dg/anew2.C: New test. + * g++.dg/anew3.C: New test. + * g++.dg/anew4.C: New test. + 2003-06-19 Kazu Hirata <kazu@cs.umass.edu> * gcc.c-torture/compile/simd-5.c: Don't XFAIL on H8. diff --git a/gcc/testsuite/g++.dg/expr/anew1.C b/gcc/testsuite/g++.dg/expr/anew1.C new file mode 100644 index 00000000000..a14408ace0a --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/anew1.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> + + +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; +} 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; +} diff --git a/gcc/testsuite/g++.dg/expr/anew3.C b/gcc/testsuite/g++.dg/expr/anew3.C new file mode 100644 index 00000000000..3223546d4c8 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/anew3.C @@ -0,0 +1,25 @@ +// { 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> + +struct X +{ + int a; + double b; +}; + +X* allocate(int n) +{ + return new X[n](); +} + +int main() +{ + const int n = 17; + X* p = allocate(n); + for (int i = 0; i < n; ++i) + if (p[i].a != 0 || p[i].b != 0.0) + return 1; + return 0; +} diff --git a/gcc/testsuite/g++.dg/expr/anew4.C b/gcc/testsuite/g++.dg/expr/anew4.C new file mode 100644 index 00000000000..8999ffb53c6 --- /dev/null +++ b/gcc/testsuite/g++.dg/expr/anew4.C @@ -0,0 +1,37 @@ +// { 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> + +struct B +{ + B(); + int n; +}; + +B::B() +{ + n = 137; +} + + +struct D : public B +{ + double x; +}; + + +D* allocate(int n) +{ + return new D[n](); +} + +int main() +{ + const int n = 17; + D* p = allocate(n); + for (int i = 0; i < n; ++i) + if (p[i].n != 137 || p[i].x != 0) + return 1; + return 0; +} |