deque.tcc (deque<>::_M_assign_aux): Cast to void to ensure overloaded comma not used.

2018-05-02  François Dumont  <fdumont@gcc.gnu.org>

	* 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<bool>::_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.

From-SVN: r259856
This commit is contained in:
François Dumont 2018-05-02 19:51:33 +00:00
parent 85d0fad469
commit 27db01d803
9 changed files with 170 additions and 4 deletions

View File

@ -1,3 +1,15 @@
2018-05-02 François Dumont <fdumont@gcc.gnu.org>
* 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<bool>::_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 <jwakely@redhat.com>
PR libstdc++/68197

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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
// <http://www.gnu.org/licenses/>.
#include <deque>
#include <testsuite_iterators.h>
#include <testsuite_hooks.h>
typedef __gnu_test::test_container<int, __gnu_test::input_iterator_wrapper>
input_iterator_seq;
int main()
{
std::deque<int> 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;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
#include <list>
#include <testsuite_iterators.h>
#include <testsuite_hooks.h>
typedef __gnu_test::test_container<int, __gnu_test::input_iterator_wrapper>
input_iterator_seq;
int main()
{
std::list<int> l;
int array[] { 0, 1, 2 };
input_iterator_seq seq(array, array + 3);
l.assign(seq.begin(), seq.end());
VERIFY( !l.empty() );
return 0;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
#include <vector>
#include <testsuite_iterators.h>
#include <testsuite_hooks.h>
void test01()
{
typedef __gnu_test::test_container<bool, __gnu_test::input_iterator_wrapper>
input_iterator_seq;
std::vector<bool> 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;
}

View File

@ -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
// <http://www.gnu.org/licenses/>.
#include <vector>
#include <testsuite_iterators.h>
#include <testsuite_hooks.h>
void test01()
{
typedef __gnu_test::test_container<int, __gnu_test::input_iterator_wrapper>
input_iterator_seq;
std::vector<int> 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;
}