diff options
Diffstat (limited to 'libstdc++-v3/include/debug')
-rw-r--r-- | libstdc++-v3/include/debug/formatter.h | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/debug/forward_list | 7 | ||||
-rw-r--r-- | libstdc++-v3/include/debug/functions.h | 276 | ||||
-rw-r--r-- | libstdc++-v3/include/debug/list | 9 | ||||
-rw-r--r-- | libstdc++-v3/include/debug/macros.h | 61 | ||||
-rw-r--r-- | libstdc++-v3/include/debug/safe_iterator.h | 3 | ||||
-rw-r--r-- | libstdc++-v3/include/debug/safe_local_iterator.h | 3 | ||||
-rw-r--r-- | libstdc++-v3/include/debug/string | 5 |
8 files changed, 207 insertions, 161 deletions
diff --git a/libstdc++-v3/include/debug/formatter.h b/libstdc++-v3/include/debug/formatter.h index 4c65e1ac4da..15dd8d73797 100644 --- a/libstdc++-v3/include/debug/formatter.h +++ b/libstdc++-v3/include/debug/formatter.h @@ -114,7 +114,9 @@ namespace __gnu_debug // unordered container buckets __msg_bucket_index_oob, __msg_valid_load_factor, - __msg_equal_allocs + // others + __msg_equal_allocs, + __msg_insert_range_from_self }; class _Error_formatter diff --git a/libstdc++-v3/include/debug/forward_list b/libstdc++-v3/include/debug/forward_list index 90a2e9c3e65..4c8ac371c94 100644 --- a/libstdc++-v3/include/debug/forward_list +++ b/libstdc++-v3/include/debug/forward_list @@ -796,6 +796,13 @@ namespace __gnu_debug _S_Is_Beginnest(_BaseIt __it, const _Sequence* __seq) { return _S_Is(__it, __seq); } }; + +#ifndef _GLIBCXX_DEBUG_PEDANTIC + template<class _Tp, class _Alloc> + struct _Insert_range_from_self_is_safe< + std::__debug::forward_list<_Tp, _Alloc> > + { enum { __value = 1 }; }; +#endif } #endif diff --git a/libstdc++-v3/include/debug/functions.h b/libstdc++-v3/include/debug/functions.h index 3f16098185c..8e76b7f2ee5 100644 --- a/libstdc++-v3/include/debug/functions.h +++ b/libstdc++-v3/include/debug/functions.h @@ -32,7 +32,12 @@ #include <bits/c++config.h> #include <bits/stl_iterator_base_types.h> // for iterator_traits, categories and // _Iter_base -#include <bits/cpp_type_traits.h> // for __is_integer +#include <bits/cpp_type_traits.h> // for __is_integer +#include <bits/move.h> // for __addressof and addressof +#if __cplusplus >= 201103L +# include <bits/stl_function.h> // for less and greater_equal +# include <type_traits> // for is_lvalue_reference and __and_ +#endif #include <debug/formatter.h> namespace __gnu_debug @@ -40,6 +45,10 @@ namespace __gnu_debug template<typename _Iterator, typename _Sequence> class _Safe_iterator; + template<typename _Sequence> + struct _Insert_range_from_self_is_safe + { enum { __value = 0 }; }; + // An arbitrary iterator pointer is not singular. inline bool __check_singular_aux(const void*) { return false; } @@ -118,8 +127,8 @@ namespace __gnu_debug inline bool __valid_range_aux(const _InputIterator& __first, const _InputIterator& __last, std::__false_type) - { return __valid_range_aux2(__first, __last, - std::__iterator_category(__first)); } + { return __valid_range_aux2(__first, __last, + std::__iterator_category(__first)); } /** Don't know what these iterators are, or if they are even * iterators (we may get an integral type for InputIterator), so @@ -162,6 +171,125 @@ namespace __gnu_debug return __first; } +#if __cplusplus >= 201103L + // Default implementation. + template<typename _Iterator, typename _Sequence> + inline bool + __foreign_iterator_aux4(const _Safe_iterator<_Iterator, _Sequence>& __it, + typename _Sequence::const_pointer __begin, + typename _Sequence::const_pointer __other) + { + typedef typename _Sequence::const_pointer _PointerType; + constexpr std::less<_PointerType> __l{}; + + return (__l(__other, __begin) + || __l(std::addressof(*(__it._M_get_sequence()->_M_base().end() + - 1)), __other)); + } + + // 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> + inline bool + __foreign_iterator_aux3(const _Safe_iterator<_Iterator, _Sequence>& __it, + _InputIterator __other, + std::true_type) + { + // Only containers with all elements in contiguous memory can have their + // elements passed through pointers. + // Arithmetics is here just to make sure we are not dereferencing + // past-the-end iterator. + if (__it._M_get_sequence()->_M_base().begin() + != __it._M_get_sequence()->_M_base().end()) + if (std::addressof(*(__it._M_get_sequence()->_M_base().end() - 1)) + - std::addressof(*(__it._M_get_sequence()->_M_base().begin())) + == __it._M_get_sequence()->size() - 1) + return (__foreign_iterator_aux4 + (__it, + std::addressof(*(__it._M_get_sequence()->_M_base().begin())), + std::addressof(*__other))); + return true; + } + + /* Fallback overload for which we can't say, assume it is valid. */ + template<typename _Iterator, typename _Sequence, typename _InputIterator> + inline bool + __foreign_iterator_aux3(const _Safe_iterator<_Iterator, _Sequence>& __it, + _InputIterator __other, + std::false_type) + { return true; } +#endif + + /** Checks that iterators do not belong to the same sequence. */ + template<typename _Iterator, typename _Sequence, typename _OtherIterator> + inline bool + __foreign_iterator_aux2(const _Safe_iterator<_Iterator, _Sequence>& __it, + const _Safe_iterator<_OtherIterator, _Sequence>& __other, + std::input_iterator_tag) + { return __it._M_get_sequence() != __other._M_get_sequence(); } + +#if __cplusplus >= 201103L + /* This overload detects when passing pointers to the contained elements + rather than using iterators. + */ + template<typename _Iterator, typename _Sequence, typename _InputIterator> + inline bool + __foreign_iterator_aux2(const _Safe_iterator<_Iterator, _Sequence>& __it, + _InputIterator __other, + std::random_access_iterator_tag) + { + typedef typename _Sequence::const_iterator _ItType; + typedef typename std::iterator_traits<_ItType>::reference _Ref; + return __foreign_iterator_aux3(__it, __other, + std::is_lvalue_reference<_Ref>()); + } +#endif + + /* Fallback overload for which we can't say, assume it is valid. */ + template<typename _Iterator, typename _Sequence, typename _InputIterator> + inline bool + __foreign_iterator_aux2(const _Safe_iterator<_Iterator, _Sequence>&, + _InputIterator, + std::input_iterator_tag) + { return true; } + + template<typename _Iterator, typename _Sequence, + typename _Integral> + inline bool + __foreign_iterator_aux(const _Safe_iterator<_Iterator, _Sequence>& __it, + _Integral __other, + std::__true_type) + { return true; } + + template<typename _Iterator, typename _Sequence, + typename _InputIterator> + inline bool + __foreign_iterator_aux(const _Safe_iterator<_Iterator, _Sequence>& __it, + _InputIterator __other, + std::__false_type) + { + return (_Insert_range_from_self_is_safe<_Sequence>::__value + || __foreign_iterator_aux2(__it, __other, + std::__iterator_category(__it))); + } + + template<typename _Iterator, typename _Sequence, + typename _InputIterator> + inline bool + __foreign_iterator(const _Safe_iterator<_Iterator, _Sequence>& __it, + _InputIterator __other) + { + typedef typename std::__is_integer<_InputIterator>::__type _Integral; + return __foreign_iterator_aux(__it, __other, _Integral()); + } + /** Checks that __s is non-NULL or __n == 0, and then returns __s. */ template<typename _CharT, typename _Integer> inline const _CharT* @@ -211,15 +339,6 @@ namespace __gnu_debug return true; } - // For performance reason, as the iterator range has been validated, check on - // random access safe iterators is done using the base iterator. - template<typename _Iterator, typename _Sequence> - inline bool - __check_sorted_aux(const _Safe_iterator<_Iterator, _Sequence>& __first, - const _Safe_iterator<_Iterator, _Sequence>& __last, - std::random_access_iterator_tag __tag) - { return __check_sorted_aux(__first.base(), __last.base(), __tag); } - // Can't check if an input iterator sequence is sorted, because we can't step // through the sequence. template<typename _InputIterator, typename _Predicate> @@ -246,17 +365,6 @@ namespace __gnu_debug return true; } - // For performance reason, as the iterator range has been validated, check on - // random access safe iterators is done using the base iterator. - template<typename _Iterator, typename _Sequence, - typename _Predicate> - inline bool - __check_sorted_aux(const _Safe_iterator<_Iterator, _Sequence>& __first, - const _Safe_iterator<_Iterator, _Sequence>& __last, - _Predicate __pred, - std::random_access_iterator_tag __tag) - { return __check_sorted_aux(__first.base(), __last.base(), __pred, __tag); } - // Determine if a sequence is sorted. template<typename _InputIterator> inline bool @@ -345,11 +453,13 @@ namespace __gnu_debug return __check_sorted_set_aux(__first, __last, __pred, _SameType()); } + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 270. Binary search requirements overly strict + // Determine if a sequence is partitioned w.r.t. this element. template<typename _ForwardIterator, typename _Tp> inline bool - __check_partitioned_lower_aux(_ForwardIterator __first, - _ForwardIterator __last, const _Tp& __value, - std::forward_iterator_tag) + __check_partitioned_lower(_ForwardIterator __first, + _ForwardIterator __last, const _Tp& __value) { while (__first != __last && *__first < __value) ++__first; @@ -362,38 +472,11 @@ namespace __gnu_debug return __first == __last; } - // For performance reason, as the iterator range has been validated, check on - // random access safe iterators is done using the base iterator. - template<typename _Iterator, typename _Sequence, typename _Tp> - inline bool - __check_partitioned_lower_aux( - const _Safe_iterator<_Iterator, _Sequence>& __first, - const _Safe_iterator<_Iterator, _Sequence>& __last, - const _Tp& __value, - std::random_access_iterator_tag __tag) - { - return __check_partitioned_lower_aux(__first.base(), __last.base(), - __value, __tag); - } - - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 270. Binary search requirements overly strict - // Determine if a sequence is partitioned w.r.t. this element. template<typename _ForwardIterator, typename _Tp> inline bool - __check_partitioned_lower(_ForwardIterator __first, + __check_partitioned_upper(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { - return __check_partitioned_lower_aux(__first, __last, __value, - std::__iterator_category(__first)); - } - - template<typename _ForwardIterator, typename _Tp> - inline bool - __check_partitioned_upper_aux(_ForwardIterator __first, - _ForwardIterator __last, const _Tp& __value, - std::forward_iterator_tag) - { while (__first != __last && !(__value < *__first)) ++__first; if (__first != __last) @@ -405,35 +488,12 @@ namespace __gnu_debug return __first == __last; } - // For performance reason, as the iterator range has been validated, check on - // random access safe iterators is done using the base iterator. - template<typename _Iterator, typename _Sequence, typename _Tp> - inline bool - __check_partitioned_upper_aux( - const _Safe_iterator<_Iterator, _Sequence>& __first, - const _Safe_iterator<_Iterator, _Sequence>& __last, - const _Tp& __value, - std::random_access_iterator_tag __tag) - { - return __check_partitioned_upper_aux(__first.base(), __last.base(), - __value, __tag); - } - - template<typename _ForwardIterator, typename _Tp> - inline bool - __check_partitioned_upper(_ForwardIterator __first, - _ForwardIterator __last, const _Tp& __value) - { - return __check_partitioned_upper_aux(__first, __last, __value, - std::__iterator_category(__first)); - } - + // Determine if a sequence is partitioned w.r.t. this element. template<typename _ForwardIterator, typename _Tp, typename _Pred> inline bool - __check_partitioned_lower_aux(_ForwardIterator __first, - _ForwardIterator __last, const _Tp& __value, - _Pred __pred, - std::forward_iterator_tag) + __check_partitioned_lower(_ForwardIterator __first, + _ForwardIterator __last, const _Tp& __value, + _Pred __pred) { while (__first != __last && bool(__pred(*__first, __value))) ++__first; @@ -446,39 +506,12 @@ namespace __gnu_debug return __first == __last; } - // For performance reason, as the iterator range has been validated, check on - // random access safe iterators is done using the base iterator. - template<typename _Iterator, typename _Sequence, - typename _Tp, typename _Pred> - inline bool - __check_partitioned_lower_aux( - const _Safe_iterator<_Iterator, _Sequence>& __first, - const _Safe_iterator<_Iterator, _Sequence>& __last, - const _Tp& __value, _Pred __pred, - std::random_access_iterator_tag __tag) - { - return __check_partitioned_lower_aux(__first.base(), __last.base(), - __value, __pred, __tag); - } - - // Determine if a sequence is partitioned w.r.t. this element. template<typename _ForwardIterator, typename _Tp, typename _Pred> inline bool - __check_partitioned_lower(_ForwardIterator __first, + __check_partitioned_upper(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Pred __pred) { - return __check_partitioned_lower_aux(__first, __last, __value, __pred, - std::__iterator_category(__first)); - } - - template<typename _ForwardIterator, typename _Tp, typename _Pred> - inline bool - __check_partitioned_upper_aux(_ForwardIterator __first, - _ForwardIterator __last, const _Tp& __value, - _Pred __pred, - std::forward_iterator_tag) - { while (__first != __last && !bool(__pred(__value, *__first))) ++__first; if (__first != __last) @@ -490,31 +523,6 @@ namespace __gnu_debug return __first == __last; } - // For performance reason, as the iterator range has been validated, check on - // random access safe iterators is done using the base iterator. - template<typename _Iterator, typename _Sequence, - typename _Tp, typename _Pred> - inline bool - __check_partitioned_upper_aux( - const _Safe_iterator<_Iterator, _Sequence>& __first, - const _Safe_iterator<_Iterator, _Sequence>& __last, - const _Tp& __value, _Pred __pred, - std::random_access_iterator_tag __tag) - { - return __check_partitioned_upper_aux(__first.base(), __last.base(), - __value, __pred, __tag); - } - - template<typename _ForwardIterator, typename _Tp, typename _Pred> - inline bool - __check_partitioned_upper(_ForwardIterator __first, - _ForwardIterator __last, const _Tp& __value, - _Pred __pred) - { - return __check_partitioned_upper_aux(__first, __last, __value, __pred, - std::__iterator_category(__first)); - } - // Helper struct to detect random access safe iterators. template<typename _Iterator> struct __is_safe_random_iterator diff --git a/libstdc++-v3/include/debug/list b/libstdc++-v3/include/debug/list index 1ae8507ca86..fd00b0148a9 100644 --- a/libstdc++-v3/include/debug/list +++ b/libstdc++-v3/include/debug/list @@ -791,4 +791,13 @@ namespace __debug } // namespace __debug } // namespace std +#ifndef _GLIBCXX_DEBUG_PEDANTIC +namespace __gnu_debug +{ + template<class _Tp, class _Alloc> + struct _Insert_range_from_self_is_safe<std::__debug::list<_Tp, _Alloc> > + { enum { __value = 1 }; }; +} +#endif + #endif diff --git a/libstdc++-v3/include/debug/macros.h b/libstdc++-v3/include/debug/macros.h index 26732c9e3e2..1e160c26c0f 100644 --- a/libstdc++-v3/include/debug/macros.h +++ b/libstdc++-v3/include/debug/macros.h @@ -72,11 +72,11 @@ _GLIBCXX_DEBUG_VERIFY(_First != _Last, \ */ #define __glibcxx_check_insert(_Position) \ _GLIBCXX_DEBUG_VERIFY(!_Position._M_singular(), \ - _M_message(__gnu_debug::__msg_insert_singular) \ + _M_message(__gnu_debug::__msg_insert_singular) \ ._M_sequence(*this, "this") \ ._M_iterator(_Position, #_Position)); \ _GLIBCXX_DEBUG_VERIFY(_Position._M_attached_to(this), \ - _M_message(__gnu_debug::__msg_insert_different) \ + _M_message(__gnu_debug::__msg_insert_different) \ ._M_sequence(*this, "this") \ ._M_iterator(_Position, #_Position)) @@ -101,15 +101,16 @@ _GLIBCXX_DEBUG_VERIFY(!_Position._M_is_end(), \ * that it reference the sequence we are inserting into, and that the * iterator range [_First, Last) is a valid (possibly empty) * range. Note that this macro is only valid when the container is a - * _Safe_sequence and the iterator is a _Safe_iterator. - * - * @todo We would like to be able to check for noninterference of - * _Position and the range [_First, _Last), but that can't (in - * general) be done. + * _Safe_sequence and the _Position iterator is a _Safe_iterator. */ #define __glibcxx_check_insert_range(_Position,_First,_Last) \ __glibcxx_check_valid_range(_First,_Last); \ -__glibcxx_check_insert(_Position) +__glibcxx_check_insert(_Position); \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First),\ + _M_message(__gnu_debug::__msg_insert_range_from_self)\ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last) \ + ._M_sequence(*this, "this")) /** Verify that we can insert the values in the iterator range * [_First, _Last) into *this after the iterator _Position. Insertion @@ -126,7 +127,12 @@ __glibcxx_check_insert(_Position) */ #define __glibcxx_check_insert_range_after(_Position,_First,_Last) \ __glibcxx_check_valid_range(_First,_Last); \ -__glibcxx_check_insert_after(_Position) +__glibcxx_check_insert_after(_Position); \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First),\ + _M_message(__gnu_debug::__msg_insert_range_from_self)\ + ._M_iterator(_First, #_First) \ + ._M_iterator(_Last, #_Last) \ + ._M_sequence(*this, "this")) /** Verify that we can erase the element referenced by the iterator * _Position. We can erase the element if the _Position iterator is @@ -223,7 +229,9 @@ _GLIBCXX_DEBUG_VERIFY(! this->empty(), \ // Verify that the iterator range [_First, _Last) is sorted #define __glibcxx_check_sorted(_First,_Last) \ __glibcxx_check_valid_range(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last), \ + _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted( \ + __gnu_debug::__base(_First), \ + __gnu_debug::__base(_Last)), \ _M_message(__gnu_debug::__msg_unsorted) \ ._M_iterator(_First, #_First) \ ._M_iterator(_Last, #_Last)) @@ -232,7 +240,9 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last), \ predicate _Pred. */ #define __glibcxx_check_sorted_pred(_First,_Last,_Pred) \ __glibcxx_check_valid_range(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last, _Pred), \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted( \ + __gnu_debug::__base(_First), \ + __gnu_debug::__base(_Last), _Pred), \ _M_message(__gnu_debug::__msg_unsorted_pred) \ ._M_iterator(_First, #_First) \ ._M_iterator(_Last, #_Last) \ @@ -242,7 +252,8 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_sorted(_First, _Last, _Pred), \ #define __glibcxx_check_sorted_set(_First1,_Last1,_First2) \ __glibcxx_check_valid_range(_First1,_Last1); \ _GLIBCXX_DEBUG_VERIFY( \ - __gnu_debug::__check_sorted_set(_First1, _Last1, _First2), \ + __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1), \ + __gnu_debug::__base(_Last1), _First2),\ _M_message(__gnu_debug::__msg_unsorted) \ ._M_iterator(_First1, #_First1) \ ._M_iterator(_Last1, #_Last1)) @@ -251,7 +262,9 @@ _GLIBCXX_DEBUG_VERIFY( \ #define __glibcxx_check_sorted_set_pred(_First1,_Last1,_First2,_Pred) \ __glibcxx_check_valid_range(_First1,_Last1); \ _GLIBCXX_DEBUG_VERIFY( \ - __gnu_debug::__check_sorted_set(_First1, _Last1, _First2, _Pred), \ + __gnu_debug::__check_sorted_set(__gnu_debug::__base(_First1), \ + __gnu_debug::__base(_Last1), \ + _First2, _Pred), \ _M_message(__gnu_debug::__msg_unsorted_pred) \ ._M_iterator(_First1, #_First1) \ ._M_iterator(_Last1, #_Last1) \ @@ -261,8 +274,9 @@ _GLIBCXX_DEBUG_VERIFY( \ w.r.t. the value _Value. */ #define __glibcxx_check_partitioned_lower(_First,_Last,_Value) \ __glibcxx_check_valid_range(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \ - _Value), \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \ + __gnu_debug::__base(_First), \ + __gnu_debug::__base(_Last), _Value), \ _M_message(__gnu_debug::__msg_unpartitioned) \ ._M_iterator(_First, #_First) \ ._M_iterator(_Last, #_Last) \ @@ -270,8 +284,9 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \ #define __glibcxx_check_partitioned_upper(_First,_Last,_Value) \ __glibcxx_check_valid_range(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \ - _Value), \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \ + __gnu_debug::__base(_First), \ + __gnu_debug::__base(_Last), _Value), \ _M_message(__gnu_debug::__msg_unpartitioned) \ ._M_iterator(_First, #_First) \ ._M_iterator(_Last, #_Last) \ @@ -281,8 +296,9 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \ w.r.t. the value _Value and predicate _Pred. */ #define __glibcxx_check_partitioned_lower_pred(_First,_Last,_Value,_Pred) \ __glibcxx_check_valid_range(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \ - _Value, _Pred), \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower( \ + __gnu_debug::__base(_First), \ + __gnu_debug::__base(_Last), _Value, _Pred), \ _M_message(__gnu_debug::__msg_unpartitioned_pred) \ ._M_iterator(_First, #_First) \ ._M_iterator(_Last, #_Last) \ @@ -293,8 +309,9 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_lower(_First, _Last, \ w.r.t. the value _Value and predicate _Pred. */ #define __glibcxx_check_partitioned_upper_pred(_First,_Last,_Value,_Pred) \ __glibcxx_check_valid_range(_First,_Last); \ -_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper(_First, _Last, \ - _Value, _Pred), \ +_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__check_partitioned_upper( \ + __gnu_debug::__base(_First), \ + __gnu_debug::__base(_Last), _Value, _Pred), \ _M_message(__gnu_debug::__msg_unpartitioned_pred) \ ._M_iterator(_First, #_First) \ ._M_iterator(_Last, #_Last) \ @@ -332,7 +349,7 @@ _GLIBCXX_DEBUG_VERIFY(_F > 0.0f, \ _M_message(__gnu_debug::__msg_valid_load_factor) \ ._M_sequence(*this, "this")) -#define __glibcxx_check_equal_allocs(_Other) \ +#define __glibcxx_check_equal_allocs(_Other) \ _GLIBCXX_DEBUG_VERIFY(this->get_allocator() == _Other.get_allocator(), \ _M_message(__gnu_debug::__msg_equal_allocs) \ ._M_sequence(*this, "this")) diff --git a/libstdc++-v3/include/debug/safe_iterator.h b/libstdc++-v3/include/debug/safe_iterator.h index b8a971b80e0..a1f7651b1bd 100644 --- a/libstdc++-v3/include/debug/safe_iterator.h +++ b/libstdc++-v3/include/debug/safe_iterator.h @@ -269,7 +269,6 @@ namespace __gnu_debug * @brief Iterator dereference. * @pre iterator is dereferenceable * @todo Make this correct w.r.t. iterators that return proxies - * @todo Use addressof() instead of & operator */ pointer operator->() const @@ -277,7 +276,7 @@ namespace __gnu_debug _GLIBCXX_DEBUG_VERIFY(this->_M_dereferenceable(), _M_message(__msg_bad_deref) ._M_iterator(*this, "this")); - return &*_M_current; + return std::__addressof(*_M_current); } // ------ Input iterator requirements ------ diff --git a/libstdc++-v3/include/debug/safe_local_iterator.h b/libstdc++-v3/include/debug/safe_local_iterator.h index 6426ed82afa..82975b70722 100644 --- a/libstdc++-v3/include/debug/safe_local_iterator.h +++ b/libstdc++-v3/include/debug/safe_local_iterator.h @@ -173,7 +173,6 @@ namespace __gnu_debug * @brief Iterator dereference. * @pre iterator is dereferenceable * @todo Make this correct w.r.t. iterators that return proxies - * @todo Use addressof() instead of & operator */ pointer operator->() const @@ -181,7 +180,7 @@ namespace __gnu_debug _GLIBCXX_DEBUG_VERIFY(this->_M_dereferenceable(), _M_message(__msg_bad_deref) ._M_iterator(*this, "this")); - return &*_M_current; + return std::__addressof(*_M_current); } // ------ Input iterator requirements ------ diff --git a/libstdc++-v3/include/debug/string b/libstdc++-v3/include/debug/string index 8a5bf9b0367..9e856c1ee8c 100644 --- a/libstdc++-v3/include/debug/string +++ b/libstdc++-v3/include/debug/string @@ -1156,6 +1156,11 @@ namespace __gnu_debug typedef basic_string<wchar_t> wstring; #endif + template<typename _CharT, typename _Traits, typename _Allocator> + struct _Insert_range_from_self_is_safe< + __gnu_debug::basic_string<_CharT, _Traits, _Allocator> > + { enum { __value = 1 }; }; + } // namespace __gnu_debug #endif |