libstdc++: Fix N3344 behavior on _Safe_iterator::_M_can_advance
We shall be able to advance from a 0 offset a value-initialized iterator. libstdc++-v3/ChangeLog: * include/debug/safe_iterator.tcc (_Safe_iterator<>::_M_can_advance): Accept 0 offset advance on value-initialized iterator. * testsuite/23_containers/vector/debug/n3644.cc: New test case.
This commit is contained in:
parent
5f6e0853c3
commit
dda96a9d94
2 changed files with 19 additions and 0 deletions
|
@ -86,6 +86,9 @@ namespace __gnu_debug
|
|||
_Safe_iterator<_Iterator, _Sequence, _Category>::
|
||||
_M_can_advance(difference_type __n, bool __strict) const
|
||||
{
|
||||
if (this->_M_value_initialized() && __n == 0)
|
||||
return true;
|
||||
|
||||
if (this->_M_singular())
|
||||
return false;
|
||||
|
||||
|
|
16
libstdc++-v3/testsuite/23_containers/vector/debug/n3644.cc
Normal file
16
libstdc++-v3/testsuite/23_containers/vector/debug/n3644.cc
Normal file
|
@ -0,0 +1,16 @@
|
|||
// { dg-do run { target c++11 } }
|
||||
// { dg-require-debug-mode "" }
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::vector<int>::iterator it{};
|
||||
auto cpy = it;
|
||||
std::advance(it, 0);
|
||||
VERIFY( it == cpy );
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue