diff options
author | Steven Bosscher <stevenb@suse.de> | 2004-12-17 17:10:49 +0000 |
---|---|---|
committer | Steven Bosscher <stevenb@suse.de> | 2004-12-17 17:10:49 +0000 |
commit | 8b01ecb9c6c214b0876d1c161d9f572b2d9c6e89 (patch) | |
tree | 656daa8a3d63c9cc904d34b7500fdf001b9e75c3 /gcc/cp/init.c | |
parent | 7a9bccbb24fa32e93a4ff66781581d84fe5a9a4e (diff) |
* init.c (build_zero_init): max_index is the number of
elements, minus 1.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@92323 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r-- | gcc/cp/init.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 90b84eb6a45..2bff006d591 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -221,7 +221,11 @@ build_zero_init (tree type, tree nelts, bool static_storage_p) init = build_constructor (type, NULL_TREE); /* Iterate over the array elements, building initializations. */ inits = NULL_TREE; - max_index = nelts ? nelts : array_type_nelts (type); + if (nelts) + max_index = fold (build2 (MINUS_EXPR, TREE_TYPE (nelts), + nelts, integer_one_node)); + else + max_index = array_type_nelts (type); gcc_assert (TREE_CODE (max_index) == INTEGER_CST); /* A zero-sized array, which is accepted as an extension, will |