* init.c (expand_vec_init): Fix off-by-one error.
authorMark Mitchell <mark@markmitchell.com>
Mon, 2 Nov 1998 22:20:39 +0000 (22:20 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Mon, 2 Nov 1998 22:20:39 +0000 (22:20 +0000)
From-SVN: r23506

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/g++.old-deja/g++.other/init10.C [new file with mode: 0644]

index 5c5ab5e9b3df8601b19d071752f033b55c6418ad..9c421f663ea8a0a88f785ed98c3346b7376f5616 100644 (file)
@@ -1,3 +1,7 @@
+1998-11-02  Mark Mitchell  <mark@markmitchell.com>
+
+       * init.c (expand_vec_init): Fix off-by-one error.
+
 1998-11-02  Alexandre Oliva  <oliva@dcc.unicamp.br>
 
        * parse.y (apparent_template_type): new type
index dbf53a31155641419bccc289ab541855d69c5b9d..78f026aeb7f215fde9e921d48ce824554eb04e70 100644 (file)
@@ -2853,10 +2853,10 @@ expand_vec_init (decl, base, maxindex, init, from_array)
       && !(TREE_CODE (maxindex) == INTEGER_CST
           && num_initialized_elts == TREE_INT_CST_LOW (maxindex) + 1))
     {
-      /* If the ITERATOR is equal to zero, then we don't have to loop;
+      /* If the ITERATOR is equal to -1, then we don't have to loop;
         we've already initialized all the elements.  */
       expand_start_cond (build (NE_EXPR, boolean_type_node,
-                               iterator, integer_zero_node), 
+                               iterator, minus_one),
                         0);
 
       /* Otherwise, loop through the elements.  */
diff --git a/gcc/testsuite/g++.old-deja/g++.other/init10.C b/gcc/testsuite/g++.old-deja/g++.other/init10.C
new file mode 100644 (file)
index 0000000..fa23813
--- /dev/null
@@ -0,0 +1,22 @@
+int i;
+
+struct D {
+  D () {
+    i++;
+  }
+};
+
+struct C {
+  C() {}
+    
+  D d[1];
+};
+
+
+int main ()
+{
+  C c;
+
+  if (i != 1)
+    return 1;
+}