From 28aa9e3ec8f13b49d7812db97aa4f21cd91c4497 Mon Sep 17 00:00:00 2001 From: bkoz Date: Fri, 14 Nov 2003 00:15:00 +0000 Subject: [PATCH] 2003-11-13 Douglas Gregor * docs/html/debug.html: Users are allowed to specialize in namespace __gnu_debug, unlike in the Apple version of the debug mode. Clear up a confusing double-negative. Note that std::basic_string does provide extra debugging capabilities, but not safe iterators. * include/bits/basic_string.tcc: Make sure there's never an ambiguity when calling __is_null_pointer. * include/debug/deque: (deque::erase) Properly handle invalidation when erasing at the end of the deque. * include/debug/vector: (vector::swap): Swap _M_guaranteed_capacity. (vector::clear): Set the guaranteed capacity to 0. * testsuite/23_containers/deque/invalidation/4.cc: (test04): Test iterator invalidation when erasing at the end of the deque. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@73564 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 16 ++++++++++++++++ libstdc++-v3/docs/html/debug.html | 8 ++++---- libstdc++-v3/docs/html/debug_mode.html | 2 +- libstdc++-v3/include/bits/basic_string.tcc | 2 +- libstdc++-v3/include/debug/deque | 2 +- libstdc++-v3/include/debug/vector | 3 +++ .../testsuite/23_containers/deque/invalidation/4.cc | 6 ++++++ 7 files changed, 32 insertions(+), 7 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 7d84d46..8ebb98a 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,19 @@ +2003-11-13 Douglas Gregor + + * docs/html/debug.html: Users are allowed to specialize in + namespace __gnu_debug, unlike in the Apple version of the debug + mode. Clear up a confusing double-negative. Note that + std::basic_string does provide extra debugging capabilities, but + not safe iterators. + * include/bits/basic_string.tcc: Make sure there's never an + ambiguity when calling __is_null_pointer. + * include/debug/deque: (deque::erase) Properly handle invalidation + when erasing at the end of the deque. + * include/debug/vector: (vector::swap): Swap _M_guaranteed_capacity. + (vector::clear): Set the guaranteed capacity to 0. + * testsuite/23_containers/deque/invalidation/4.cc: (test04): Test + iterator invalidation when erasing at the end of the deque. + 2003-11-13 Paolo Carlini Petur Runolfsson diff --git a/libstdc++-v3/docs/html/debug.html b/libstdc++-v3/docs/html/debug.html index be4a861..91e13c1 100644 --- a/libstdc++-v3/docs/html/debug.html +++ b/libstdc++-v3/docs/html/debug.html @@ -145,8 +145,7 @@ functionally equivalent to the standard drop-in containers used in debug mode, but they are available in a separate namespace as GNU extensions and may be used in programs compiled with either release - mode or with debug mode. However, unlike the containers in namespace - std, these containers may not be specialized. The + mode or with debug mode. The following table provides the names and headers of the debugging containers: @@ -250,7 +249,7 @@

Debug mode semantics

-

A program that does not use the C++ standard library incorrectly +

A program that uses the C++ standard library correctly will maintain the same semantics under debug mode as it had with the normal (release) library. All functional and exception-handling guarantees made by the normal library also hold for the debug mode @@ -276,7 +275,7 @@ library, and is therefore somewhat hazardous. For this reason, the libstdc++ debug mode offers a "pedantic" mode (similar to GCC's -pedantic compiler flag) that attempts to emulate - the semantics guaranteed by the C++ standard. In pedantic mode, for + the semantics guaranteed by the C++ standard. For instance, constructing a std::basic_string with a NULL character pointer would result in an exception under normal mode or non-pedantic debug mode (this is a libstdc++ extension), whereas @@ -288,6 +287,7 @@

The following library components provide extra debugging capabilities in debug mode:

    +
  • std::basic_string (no safe iterators)
  • std::bitset
  • std::deque
  • __gnu_cxx::hash_map
  • diff --git a/libstdc++-v3/docs/html/debug_mode.html b/libstdc++-v3/docs/html/debug_mode.html index cc42dd2..b62ad8f 100644 --- a/libstdc++-v3/docs/html/debug_mode.html +++ b/libstdc++-v3/docs/html/debug_mode.html @@ -330,7 +330,7 @@ template<typename _Tp, typename _Allocator = allocator<_Tp>

    In release mode, we define only the release-mode version of the component with its standard name and do not include the debugging component at all. The release mode version is defined within the - namespace __gnu_nom, and then associated with namespace + namespace __gnu_norm, and then associated with namespace std via a "strong using" directive. Minus the namespace associations, this method leaves the behavior of release mode completely unchanged from its behavior prior to the diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc index 34a373c..204757b 100644 --- a/libstdc++-v3/include/bits/basic_string.tcc +++ b/libstdc++-v3/include/bits/basic_string.tcc @@ -52,7 +52,7 @@ namespace std template inline bool - __is_null_pointer(const _Type&) + __is_null_pointer(_Type) { return false; } template diff --git a/libstdc++-v3/include/debug/deque b/libstdc++-v3/include/debug/deque index b9d68af..818d59e 100644 --- a/libstdc++-v3/include/debug/deque +++ b/libstdc++-v3/include/debug/deque @@ -294,7 +294,7 @@ namespace __gnu_debug_def // _GLIBCXX_RESOLVE_LIB_DEFECTS // 151. can't currently clear() empty container __glibcxx_check_erase_range(__first, __last); - if (__first == begin() || __last == end()-1) + if (__first == begin() || __last == end()) { this->_M_detach_singular(); for (iterator __position = __first; __position != __last; ) diff --git a/libstdc++-v3/include/debug/vector b/libstdc++-v3/include/debug/vector index 19249b6..53e6f0c 100644 --- a/libstdc++-v3/include/debug/vector +++ b/libstdc++-v3/include/debug/vector @@ -34,6 +34,7 @@ #include #include #include +#include namespace __gnu_debug_def { @@ -328,6 +329,7 @@ namespace __gnu_debug_def { _Base::swap(__x); this->_M_swap(__x); + std::swap(_M_guaranteed_capacity, __x._M_guaranteed_capacity); } void @@ -335,6 +337,7 @@ namespace __gnu_debug_def { _Base::clear(); this->_M_invalidate_all(); + _M_guaranteed_capacity = 0; } _Base& diff --git a/libstdc++-v3/testsuite/23_containers/deque/invalidation/4.cc b/libstdc++-v3/testsuite/23_containers/deque/invalidation/4.cc index 1918737..c8a8b88 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/invalidation/4.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/invalidation/4.cc @@ -55,6 +55,12 @@ void test04() VERIFY(before._M_singular()); VERIFY(at._M_singular()); + // Multiple element erase at end + before = v.begin(); + at = before + 3; + v.erase(at, v.end()); + *before; + // clear() before = v.begin(); VERIFY(before._M_dereferenceable()); -- 2.7.4