init.c (build_zero_init): max_index is the number of elements, minus 1.
authorSteven Bosscher <stevenb@suse.de>
Fri, 17 Dec 2004 17:10:49 +0000 (17:10 +0000)
committerSteven Bosscher <steven@gcc.gnu.org>
Fri, 17 Dec 2004 17:10:49 +0000 (17:10 +0000)
* init.c (build_zero_init): max_index is the number of
elements, minus 1.

From-SVN: r92323

gcc/cp/ChangeLog
gcc/cp/init.c

index eb6cb4faf0225c780b19e3a774d3c704c2731cf4..2007959dee3e708bd0d5d71877fed0b8488acdc6 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-17  Steven Bosscher  <stevenb@suse.de>
+
+       * init.c (build_zero_init): max_index is the number of
+       elements, minus 1.
+
 2004-12-17  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/18721
index 90b84eb6a45c2b5dc51a32422f0ac919bc28290a..2bff006d591905f0e65cf1f20f890d75bc29f9ef 100644 (file)
@@ -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