diff options
author | Mark Mitchell <mark@markmitchell.com> | 1998-11-02 22:20:39 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1998-11-02 22:20:39 +0000 |
commit | 37e05cd585cb3fe846ee4ab58bf51e9caf0649f6 (patch) | |
tree | c287655539a6ba44669e1cfa00c213a5f1e3ee64 /gcc | |
parent | 0ae9f65b6ba43c4807801a4570b1e5441cea0c24 (diff) | |
download | gcc-37e05cd585cb3fe846ee4ab58bf51e9caf0649f6.zip gcc-37e05cd585cb3fe846ee4ab58bf51e9caf0649f6.tar.gz gcc-37e05cd585cb3fe846ee4ab58bf51e9caf0649f6.tar.bz2 |
* init.c (expand_vec_init): Fix off-by-one error.
From-SVN: r23506
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/init.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.other/init10.C | 22 |
3 files changed, 28 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5c5ab5e..9c421f6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index dbf53a3..78f026a 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 0000000..fa23813 --- /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; +} |