Commit 32bb816a by François Dumont

re PR libstdc++/58148 (Fails to insert iterator range into sequence container…

re PR libstdc++/58148 (Fails to insert iterator range into sequence container with -D_GLIBCXX_DEBUG when conversion is needed)

2013-08-30  François Dumont  <fdumont@gcc.gnu.org>

	PR libstdc++/58148
	* include/debug/functions.h (__foreign_iterator_aux4): Use
	sequence const_pointer as common type to compare pointers. Add a
	fallback overload in case pointers cannot be cast to sequence
	const_pointer.
	* testsuite/23_containers/vector/modifiers/insert/58148.cc: New.

From-SVN: r202121
parent 8915a229
2013-08-30 François Dumont <fdumont@gcc.gnu.org> 2013-08-30 François Dumont <fdumont@gcc.gnu.org>
PR libstdc++/58148
* include/debug/functions.h (__foreign_iterator_aux4): Use
sequence const_pointer as common type to compare pointers. Add a
fallback overload in case pointers cannot be cast to sequence
const_pointer.
* testsuite/23_containers/vector/modifiers/insert/58148.cc: New.
2013-08-30 François Dumont <fdumont@gcc.gnu.org>
PR libstdc++/58191 PR libstdc++/58191
* include/debug/macros.h (__glibcxx_check_partitioned_lower): Add * include/debug/macros.h (__glibcxx_check_partitioned_lower): Add
__gnu_debug::__base calls on iterators passed to internal debug __gnu_debug::__base calls on iterators passed to internal debug
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include <bits/move.h> // for __addressof and addressof #include <bits/move.h> // for __addressof and addressof
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
# include <bits/stl_function.h> // for less and greater_equal # include <bits/stl_function.h> // for less and greater_equal
# include <type_traits> // for common_type # include <type_traits> // for is_lvalue_reference and __and_
#endif #endif
#include <debug/formatter.h> #include <debug/formatter.h>
...@@ -172,27 +172,30 @@ namespace __gnu_debug ...@@ -172,27 +172,30 @@ namespace __gnu_debug
} }
#if __cplusplus >= 201103L #if __cplusplus >= 201103L
template<typename _Iterator, typename _Sequence, // Default implementation.
typename _InputIterator, template<typename _Iterator, typename _Sequence>
typename _PointerType1,
typename _PointerType2>
inline bool inline bool
__foreign_iterator_aux4(const _Safe_iterator<_Iterator, _Sequence>& __it, __foreign_iterator_aux4(const _Safe_iterator<_Iterator, _Sequence>& __it,
_InputIterator __other, typename _Sequence::const_pointer __begin,
_PointerType1, _PointerType2) typename _Sequence::const_pointer __other)
{ {
typedef typename std::common_type<_PointerType1, typedef typename _Sequence::const_pointer _PointerType;
_PointerType2>::type _PointerType;
constexpr std::less<_PointerType> __l{}; constexpr std::less<_PointerType> __l{};
constexpr std::greater_equal<_PointerType> __ge{};
return (__l(std::addressof(*__other), return (__l(__other, __begin)
std::addressof(*(__it._M_get_sequence()->_M_base().begin()))) || __l(std::addressof(*(__it._M_get_sequence()->_M_base().end()
|| __ge(std::addressof(*__other), - 1)), __other));
std::addressof(*(__it._M_get_sequence()->_M_base().end()
- 1)) + 1));
} }
// Fallback when address type cannot be implicitely casted to sequence
// const_pointer.
template<typename _Iterator, typename _Sequence,
typename _InputIterator>
inline bool
__foreign_iterator_aux4(const _Safe_iterator<_Iterator, _Sequence>&,
_InputIterator, ...)
{ return true; }
template<typename _Iterator, typename _Sequence, typename _InputIterator> template<typename _Iterator, typename _Sequence, typename _InputIterator>
inline bool inline bool
__foreign_iterator_aux3(const _Safe_iterator<_Iterator, _Sequence>& __it, __foreign_iterator_aux3(const _Safe_iterator<_Iterator, _Sequence>& __it,
...@@ -209,7 +212,7 @@ namespace __gnu_debug ...@@ -209,7 +212,7 @@ namespace __gnu_debug
- std::addressof(*(__it._M_get_sequence()->_M_base().begin())) - std::addressof(*(__it._M_get_sequence()->_M_base().begin()))
== __it._M_get_sequence()->size() - 1) == __it._M_get_sequence()->size() - 1)
return (__foreign_iterator_aux4 return (__foreign_iterator_aux4
(__it, __other, (__it,
std::addressof(*(__it._M_get_sequence()->_M_base().begin())), std::addressof(*(__it._M_get_sequence()->_M_base().begin())),
std::addressof(*__other))); std::addressof(*__other)));
return true; return true;
...@@ -223,7 +226,7 @@ namespace __gnu_debug ...@@ -223,7 +226,7 @@ namespace __gnu_debug
std::false_type) std::false_type)
{ return true; } { return true; }
#endif #endif
/** Checks that iterators do not belong to the same sequence. */ /** Checks that iterators do not belong to the same sequence. */
template<typename _Iterator, typename _Sequence, typename _OtherIterator> template<typename _Iterator, typename _Sequence, typename _OtherIterator>
inline bool inline bool
......
// Copyright (C) 2013 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/>.
// { dg-options "-std=gnu++11" }
// { dg-do compile }
#include <vector>
void
test01()
{
std::vector<wchar_t> v;
char c = 'a';
v.insert(v.begin(), &c, &c);
}
int main()
{
test01();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment