diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index b251187813f..69a9eeba469 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,15 @@ +2018-05-02 François Dumont + + * include/bits/deque.tcc (deque<>::_M_assign_aux): Cast to void to + ensure overloaded comma not used. + * include/bits/list.tcc (list<>::_M_assign_dispatch): Likewise. + * include/bits/vector.tcc (vector<>::_M_assign_aux): Likewise. + * include/bits/stl_bvector.h (vector::_M_assign_aux): Likewise. + * testsuite/23_containers/deque/modifiers/assign/1.cc: New. + * testsuite/23_containers/list/modifiers/assign/1.cc: New. + * testsuite/23_containers/vector/bool/modifiers/assign/1.cc: New. + * testsuite/23_containers/vector/modifiers/assign/1.cc: New. + 2018-05-02 Jonathan Wakely PR libstdc++/68197 diff --git a/libstdc++-v3/include/bits/deque.tcc b/libstdc++-v3/include/bits/deque.tcc index a00f57885df..8724a19504b 100644 --- a/libstdc++-v3/include/bits/deque.tcc +++ b/libstdc++-v3/include/bits/deque.tcc @@ -291,7 +291,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER std::input_iterator_tag) { iterator __cur = begin(); - for (; __first != __last && __cur != end(); ++__cur, ++__first) + for (; __first != __last && __cur != end(); ++__cur, (void)++__first) *__cur = *__first; if (__first == __last) _M_erase_at_end(__cur); diff --git a/libstdc++-v3/include/bits/list.tcc b/libstdc++-v3/include/bits/list.tcc index 22538c9fc7a..e90d9574cd2 100644 --- a/libstdc++-v3/include/bits/list.tcc +++ b/libstdc++-v3/include/bits/list.tcc @@ -312,7 +312,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER iterator __first1 = begin(); iterator __last1 = end(); for (; __first1 != __last1 && __first2 != __last2; - ++__first1, ++__first2) + ++__first1, (void)++__first2) *__first1 = *__first2; if (__first2 == __last2) erase(__first1, __last1); diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index de723edf50c..24594044d7a 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -1221,7 +1221,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER std::input_iterator_tag) { iterator __cur = begin(); - for (; __first != __last && __cur != end(); ++__cur, ++__first) + for (; __first != __last && __cur != end(); ++__cur, (void)++__first) *__cur = *__first; if (__first == __last) _M_erase_at_end(__cur); diff --git a/libstdc++-v3/include/bits/vector.tcc b/libstdc++-v3/include/bits/vector.tcc index fb6d7e00989..1d1ef427b26 100644 --- a/libstdc++-v3/include/bits/vector.tcc +++ b/libstdc++-v3/include/bits/vector.tcc @@ -273,7 +273,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { pointer __cur(this->_M_impl._M_start); for (; __first != __last && __cur != this->_M_impl._M_finish; - ++__cur, ++__first) + ++__cur, (void)++__first) *__cur = *__first; if (__first == __last) _M_erase_at_end(__cur); diff --git a/libstdc++-v3/testsuite/23_containers/deque/modifiers/assign/1.cc b/libstdc++-v3/testsuite/23_containers/deque/modifiers/assign/1.cc new file mode 100644 index 00000000000..fbab09b9ba2 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/modifiers/assign/1.cc @@ -0,0 +1,36 @@ +// Copyright (C) 2018 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +#include +#include + +typedef __gnu_test::test_container + input_iterator_seq; + +int main() +{ + std::deque d; + + int array[] { 0, 1, 2 }; + input_iterator_seq seq(array, array + 3); + + d.assign(seq.begin(), seq.end()); + VERIFY( d.size() == 3 ); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/assign/1.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/assign/1.cc new file mode 100644 index 00000000000..c5fde47059a --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/assign/1.cc @@ -0,0 +1,36 @@ +// Copyright (C) 2018 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +#include +#include + +typedef __gnu_test::test_container + input_iterator_seq; + +int main() +{ + std::list l; + + int array[] { 0, 1, 2 }; + input_iterator_seq seq(array, array + 3); + + l.assign(seq.begin(), seq.end()); + VERIFY( !l.empty() ); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/assign/1.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/assign/1.cc new file mode 100644 index 00000000000..833201b39a3 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/assign/1.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2018 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +#include +#include + +void test01() +{ + typedef __gnu_test::test_container + input_iterator_seq; + + std::vector bv; + + bool array[] { false, true, true }; + input_iterator_seq seq(array, array + 3); + + bv.assign(seq.begin(), seq.end()); + VERIFY( bv.size() == 3 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/modifiers/assign/1.cc b/libstdc++-v3/testsuite/23_containers/vector/modifiers/assign/1.cc new file mode 100644 index 00000000000..ca7b125e7ca --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/modifiers/assign/1.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2018 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +#include +#include + +void test01() +{ + typedef __gnu_test::test_container + input_iterator_seq; + + std::vector v; + + int array[] { 0, 1, 2 }; + input_iterator_seq seq(array, array + 3); + + v.assign(seq.begin(), seq.end()); + VERIFY( v.size() == 3 ); +} + +int main() +{ + test01(); + return 0; +}