From 6b6c8106ab4e65320e3a9a4202ac49739927720f Mon Sep 17 00:00:00 2001 From: Steven Bosscher Date: Fri, 17 Dec 2004 17:10:49 +0000 Subject: init.c (build_zero_init): max_index is the number of elements, minus 1. * init.c (build_zero_init): max_index is the number of elements, minus 1. From-SVN: r92323 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/init.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index eb6cb4f..2007959 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2004-12-17 Steven Bosscher + + * init.c (build_zero_init): max_index is the number of + elements, minus 1. + 2004-12-17 Nathan Sidwell PR c++/18721 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 90b84eb..2bff006 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 -- cgit v1.1