Fix safe iterator inconsistent assertion

Message ID 7b34a128-b536-9686-e6eb-7b5b84b8025d@gmail.com
State New
Headers show
Series
  • Fix safe iterator inconsistent assertion
Related show

Commit Message

François Dumont June 21, 2018, 5:36 a.m.
Working on iterator == operator I noticed that a comparison in 
_Safe_iterator was inconsistent.

     * include/debug/debug.h
     (_Safe_iterator<>(const _Safe_iterator<_MutableIterator,>& __x)):
     Compare __x base iterator with a default initialized iterator of the
     same type.

Tested under linux x86_64.

François

Comments

Jonathan Wakely June 21, 2018, 9:27 a.m. | #1
On 21/06/18 07:36 +0200, François Dumont wrote:
>Working on iterator == operator I noticed that a comparison in 

>_Safe_iterator was inconsistent.

>

>    * include/debug/debug.h


Wrong filename in the ChangeLog here.

>    (_Safe_iterator<>(const _Safe_iterator<_MutableIterator,>& __x)):

>    Compare __x base iterator with a default initialized iterator of the

>    same type.


Please say value-initialized not default initialized (that's what
you're actually doing, and [forward.iterators] p2 only makes it
well-defined for value-initialized iterators).

OK with those changes to the ChangeLog, thanks.

Patch

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 261830)
+++ ChangeLog	(working copy)
@@ -1,3 +1,10 @@ 
+2018-06-21  François Dumont  <fdumont@gcc.gnu.org>
+
+	* include/debug/debug.h
+	(_Safe_iterator<>(const _Safe_iterator<_MutableIterator,>& __x)):
+	Compare __x base iterator with a default initialized iterator of the
+	same type.
+
 2018-06-20  Jonathan Wakely  <jwakely@redhat.com>
 
 	PR libstdc++/70966
Index: include/debug/safe_iterator.h
===================================================================
--- include/debug/safe_iterator.h	(revision 261830)
+++ include/debug/safe_iterator.h	(working copy)
@@ -180,7 +180,7 @@ 
 	  // _GLIBCXX_RESOLVE_LIB_DEFECTS
 	  // DR 408. Is vector<reverse_iterator<char*> > forbidden?
 	  _GLIBCXX_DEBUG_VERIFY(!__x._M_singular()
-				|| __x.base() == _Iterator(),
+				|| __x.base() == _MutableIterator(),
 				_M_message(__msg_init_const_singular)
 				._M_iterator(*this, "this")
 				._M_iterator(__x, "other"));