From: Mark Mitchell Date: Mon, 2 Nov 1998 22:20:39 +0000 (+0000) Subject: * init.c (expand_vec_init): Fix off-by-one error. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=37e05cd585cb3fe846ee4ab58bf51e9caf0649f6;p=gcc.git * init.c (expand_vec_init): Fix off-by-one error. From-SVN: r23506 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5c5ab5e9b3d..9c421f663ea 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,7 @@ +1998-11-02 Mark Mitchell + + * init.c (expand_vec_init): Fix off-by-one error. + 1998-11-02 Alexandre Oliva * parse.y (apparent_template_type): new type diff --git a/gcc/cp/init.c b/gcc/cp/init.c index dbf53a31155..78f026aeb7f 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -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 index 00000000000..fa238132f3f --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/init10.C @@ -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; +}