libstdc++: Implement N3644 on _Safe_iterator<> [PR114316]
Consider range of value-initialized iterators as valid and empty. libstdc++-v3/ChangeLog: PR libstdc++/114316 * include/debug/safe_iterator.tcc (_Safe_iterator<>::_M_valid_range): First check if both iterators are value-initialized before checking if singular. * testsuite/23_containers/set/debug/114316.cc: New test case. * testsuite/23_containers/vector/debug/114316.cc: New test case.
This commit is contained in:
parent
f065c582d9
commit
07fad7a7fc
3 changed files with 44 additions and 0 deletions
|
@ -194,6 +194,12 @@ namespace __gnu_debug
|
|||
std::pair<difference_type, _Distance_precision>& __dist,
|
||||
bool __check_dereferenceable) const
|
||||
{
|
||||
if (_M_value_initialized() && __rhs._M_value_initialized())
|
||||
{
|
||||
__dist = std::make_pair(0, __dp_exact);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_M_singular() || __rhs._M_singular() || !_M_can_compare(__rhs))
|
||||
return false;
|
||||
|
||||
|
@ -218,6 +224,12 @@ namespace __gnu_debug
|
|||
std::pair<difference_type,
|
||||
_Distance_precision>& __dist) const
|
||||
{
|
||||
if (this->_M_value_initialized() && __rhs._M_value_initialized())
|
||||
{
|
||||
__dist = std::make_pair(0, __dp_exact);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this->_M_singular() || __rhs._M_singular()
|
||||
|| !this->_M_can_compare(__rhs))
|
||||
return false;
|
||||
|
|
16
libstdc++-v3/testsuite/23_containers/set/debug/114316.cc
Normal file
16
libstdc++-v3/testsuite/23_containers/set/debug/114316.cc
Normal file
|
@ -0,0 +1,16 @@
|
|||
// { dg-do run { target c++11 } }
|
||||
// { dg-require-debug-mode "" }
|
||||
|
||||
// PR libstdc++/114316
|
||||
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::set<int>::iterator it{};
|
||||
VERIFY( std::find(it, it, 0) == it );
|
||||
return 0;
|
||||
}
|
16
libstdc++-v3/testsuite/23_containers/vector/debug/114316.cc
Normal file
16
libstdc++-v3/testsuite/23_containers/vector/debug/114316.cc
Normal file
|
@ -0,0 +1,16 @@
|
|||
// { dg-do run { target c++11 } }
|
||||
// { dg-require-debug-mode "" }
|
||||
|
||||
// PR libstdc++/114316
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include <testsuite_hooks.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::vector<int>::iterator it{};
|
||||
VERIFY( std::find(it, it, 0) == it );
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue