debug.html: Users are allowed to specialize in namespace __gnu_debug...

2003-11-13  Douglas Gregor  <gregod@cs.rpi.edu>

	* 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.

From-SVN: r73564
This commit is contained in:
Douglas Gregor 2003-11-14 00:15:00 +00:00 committed by Benjamin Kosnik
parent a2dcfada8a
commit 1b80d64af2
7 changed files with 32 additions and 7 deletions

View File

@ -1,3 +1,19 @@
2003-11-13 Douglas Gregor <gregod@cs.rpi.edu>
* 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 <pcarlini@suse.de> 2003-11-13 Paolo Carlini <pcarlini@suse.de>
Petur Runolfsson <peturr02@ru.is> Petur Runolfsson <peturr02@ru.is>

View File

@ -145,8 +145,7 @@
functionally equivalent to the standard drop-in containers used in functionally equivalent to the standard drop-in containers used in
debug mode, but they are available in a separate namespace as GNU debug mode, but they are available in a separate namespace as GNU
extensions and may be used in programs compiled with either release extensions and may be used in programs compiled with either release
mode or with debug mode. However, unlike the containers in namespace mode or with debug mode. The
<code>std</code>, these containers may not be specialized. The
following table provides the names and headers of the debugging following table provides the names and headers of the debugging
containers: containers:
@ -250,7 +249,7 @@
</table> </table>
<h4 class="left">Debug mode semantics</h4> <h4 class="left">Debug mode semantics</h4>
<p>A program that does not use the C++ standard library incorrectly <p>A program that uses the C++ standard library correctly
will maintain the same semantics under debug mode as it had with will maintain the same semantics under debug mode as it had with
the normal (release) library. All functional and exception-handling the normal (release) library. All functional and exception-handling
guarantees made by the normal library also hold for the debug mode 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 library, and is therefore somewhat hazardous. For this reason, the
libstdc++ debug mode offers a "pedantic" mode (similar to libstdc++ debug mode offers a "pedantic" mode (similar to
GCC's <code>-pedantic</code> compiler flag) that attempts to emulate GCC's <code>-pedantic</code> 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 <code>std::basic_string</code> with a NULL instance, constructing a <code>std::basic_string</code> with a NULL
character pointer would result in an exception under normal mode or character pointer would result in an exception under normal mode or
non-pedantic debug mode (this is a libstdc++ extension), whereas non-pedantic debug mode (this is a libstdc++ extension), whereas
@ -288,6 +287,7 @@
<p>The following library components provide extra debugging <p>The following library components provide extra debugging
capabilities in debug mode:</p> capabilities in debug mode:</p>
<ul> <ul>
<li><code>std::basic_string</code> (no safe iterators)</li>
<li><code>std::bitset</code></li> <li><code>std::bitset</code></li>
<li><code>std::deque</code></li> <li><code>std::deque</code></li>
<li><code>__gnu_cxx::hash_map</code></li> <li><code>__gnu_cxx::hash_map</code></li>

View File

@ -330,7 +330,7 @@ template&lt;typename _Tp, typename _Allocator = allocator&lt;_Tp&gt;
<p>In release mode, we define only the release-mode version of the <p>In release mode, we define only the release-mode version of the
component with its standard name and do not include the debugging component with its standard name and do not include the debugging
component at all. The release mode version is defined within the component at all. The release mode version is defined within the
namespace <code>__gnu_nom</code>, and then associated with namespace namespace <code>__gnu_norm</code>, and then associated with namespace
<code>std</code> via a "strong using" directive. Minus the <code>std</code> via a "strong using" directive. Minus the
namespace associations, this method leaves the behavior of release namespace associations, this method leaves the behavior of release
mode completely unchanged from its behavior prior to the mode completely unchanged from its behavior prior to the

View File

@ -52,7 +52,7 @@ namespace std
template<typename _Type> template<typename _Type>
inline bool inline bool
__is_null_pointer(const _Type&) __is_null_pointer(_Type)
{ return false; } { return false; }
template<typename _CharT, typename _Traits, typename _Alloc> template<typename _CharT, typename _Traits, typename _Alloc>

View File

@ -294,7 +294,7 @@ namespace __gnu_debug_def
// _GLIBCXX_RESOLVE_LIB_DEFECTS // _GLIBCXX_RESOLVE_LIB_DEFECTS
// 151. can't currently clear() empty container // 151. can't currently clear() empty container
__glibcxx_check_erase_range(__first, __last); __glibcxx_check_erase_range(__first, __last);
if (__first == begin() || __last == end()-1) if (__first == begin() || __last == end())
{ {
this->_M_detach_singular(); this->_M_detach_singular();
for (iterator __position = __first; __position != __last; ) for (iterator __position = __first; __position != __last; )

View File

@ -34,6 +34,7 @@
#include <vector> #include <vector>
#include <debug/safe_sequence.h> #include <debug/safe_sequence.h>
#include <debug/safe_iterator.h> #include <debug/safe_iterator.h>
#include <utility>
namespace __gnu_debug_def namespace __gnu_debug_def
{ {
@ -328,6 +329,7 @@ namespace __gnu_debug_def
{ {
_Base::swap(__x); _Base::swap(__x);
this->_M_swap(__x); this->_M_swap(__x);
std::swap(_M_guaranteed_capacity, __x._M_guaranteed_capacity);
} }
void void
@ -335,6 +337,7 @@ namespace __gnu_debug_def
{ {
_Base::clear(); _Base::clear();
this->_M_invalidate_all(); this->_M_invalidate_all();
_M_guaranteed_capacity = 0;
} }
_Base& _Base&

View File

@ -55,6 +55,12 @@ void test04()
VERIFY(before._M_singular()); VERIFY(before._M_singular());
VERIFY(at._M_singular()); VERIFY(at._M_singular());
// Multiple element erase at end
before = v.begin();
at = before + 3;
v.erase(at, v.end());
*before;
// clear() // clear()
before = v.begin(); before = v.begin();
VERIFY(before._M_dereferenceable()); VERIFY(before._M_dereferenceable());