diff options
author | Matt Austern <austern@apple.com> | 2003-06-20 00:33:58 +0000 |
---|---|---|
committer | Matt Austern <austern@gcc.gnu.org> | 2003-06-20 00:33:58 +0000 |
commit | 7a1d37e9102a1bbc34b4544161ddf283c667bc0b (patch) | |
tree | 179855e458e087c8af77e7b247e9693d89ff9b45 /gcc/cp | |
parent | 3a95fe8f332b8ab061d7a6d269ef0ed6ea004b07 (diff) | |
download | gcc-7a1d37e9102a1bbc34b4544161ddf283c667bc0b.zip gcc-7a1d37e9102a1bbc34b4544161ddf283c667bc0b.tar.gz gcc-7a1d37e9102a1bbc34b4544161ddf283c667bc0b.tar.bz2 |
Fix for PR c++/11228, infinite loop for new int[n]().
From-SVN: r68235
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/init.c | 8 |
2 files changed, 15 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0b620d6..ba1fb35 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2003-06-19 Matt Austern <austern@apple.com> + + PR c++/11228 + * init.c (build_zero_init): Assert that number of array elements + is an integer constant. + (build_default_init) Don't use build_zero_init for arrays with + variable number of elements. + 2003-06-19 Andreas Jaeger <aj@suse.de> * cp-tree.h: Remove duplicated declarations. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 59395ee..710f617 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -180,6 +180,9 @@ build_zero_init (tree type, tree nelts, bool static_storage_p) -- if T is a reference type, no initialization is performed. */ + my_friendly_assert (nelts == NULL_TREE || TREE_CODE (nelts) == INTEGER_CST, + 20030618); + if (type == error_mark_node) ; else if (static_storage_p && zero_init_p (type)) @@ -232,6 +235,8 @@ build_zero_init (tree type, tree nelts, bool static_storage_p) /* Iterate over the array elements, building initializations. */ inits = NULL_TREE; max_index = nelts ? nelts : array_type_nelts (type); + my_friendly_assert (TREE_CODE (max_index) == INTEGER_CST, 20030618); + for (index = size_zero_node; !tree_int_cst_lt (max_index, index); index = size_binop (PLUS_EXPR, index, size_one_node)) @@ -291,7 +296,8 @@ build_default_init (tree type, tree nelts) standard says we should have generated would be precisely the same as that obtained by calling build_zero_init below, so things work out OK. */ - if (TYPE_NEEDS_CONSTRUCTING (type)) + if (TYPE_NEEDS_CONSTRUCTING (type) + || (nelts && TREE_CODE (nelts) != INTEGER_CST)) return NULL_TREE; /* At this point, TYPE is either a POD class type, an array of POD |