https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106175

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |WORKSFORME

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
How do you get the begin iterator from another iterator? That's impossible in
general. The std::prev function has no access to the vector, it can't call
begin on it.

For the debug mode, we already abort when you use prev on the begin iterator:


In function:
    gnu_debug::_Safe_iterator<_Iterator, _Sequence, 
    std::random_access_iterator_tag>& gnu_debug::_Safe_iterator<_Iterator, 
    _Sequence, std::random_access_iterator_tag>::operator+=(difference_type) 
    [with _Iterator = gnu_cxx::normal_iterator<int*, std::vector<int, 
    std::allocator<int> > >; _Sequence = std::debug::vector<int>; 
    difference_type = long int]

Error: attempt to advance a past-the-end iterator -1 steps, which falls 
outside its valid range.

Objects involved in the operation:
    iterator @ 0x7fff987ee7a0 {
      type = gnu_cxx::normal_iterator<int*, std::vector<int,
std::allocator<int> > > (mutable iterator);
      state = past-the-end;
      references sequence with type 'std::debug::vector<int,
std::allocator<int> >' @ 0x7fff987ee730
    }

Reply via email to