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

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

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jose Dapena Paz from comment #0)
> As far as I know, the specification does not really say this is a valid
> case.

It explicitly says it's NOT valid:

 Expects: The iterator following position is dereferenceable.

This is undefined behaviour. Debug Mode will diagnose it at runtime:

/usr/include/c++/8/debug/forward_list:459:
Error: function requires a valid iterator range (__pos, __last), "__pos" 
shall be before and not equal to "__last".

Objects involved in the operation:
    sequence "this" @ 0x0x7ffde677a260 {
      type = std::__debug::forward_list<int, std::allocator<int> >;
    }
    iterator "__pos" @ 0x0x7ffde677a2f0 {
      type =
__gnu_debug::_Safe_iterator<std::__cxx1998::_Fwd_list_const_iterator<int>,
std::__debug::forward_list<int, std::allocator<int> > > (constant iterator);
      state = dereferenceable;
      references sequence with type 'std::__debug::forward_list<int,
std::allocator<int> >' @ 0x0x7ffde677a260
    }
    iterator "__last" @ 0x0x7ffde677a2c0 {
      type =
__gnu_debug::_Safe_iterator<std::__cxx1998::_Fwd_list_const_iterator<int>,
std::__debug::forward_list<int, std::allocator<int> > > (constant iterator);
      state = dereferenceable;
      references sequence with type 'std::__debug::forward_list<int,
std::allocator<int> >' @ 0x0x7ffde677a260
    }
Aborted (core dumped)

Reply via email to