commit fb061814aa724727c5761b53e5a60007355da210 Author: Jonathan Wakely Date: Thu Feb 27 11:20:54 2020 libstdc++: Detect null __normal_iterator in valid range checks Enahnce debug mode checks for valid ranges to detect value-initialized __normal_iterator objects, so that basic_string iterators can be checked. Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * include/debug/helper_functions.h (__check_singular): Add overload for __normal_iterator that checks for value-initialized iterators. diff --git a/libstdc++-v3/include/debug/helper_functions.h b/libstdc++-v3/include/debug/helper_functions.h index c0144ced979..e0c69151e3a 100644 --- a/libstdc++-v3/include/debug/helper_functions.h +++ b/libstdc++-v3/include/debug/helper_functions.h @@ -36,6 +36,13 @@ #include // for pair +namespace __gnu_cxx +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + template class __normal_iterator; +_GLIBCXX_END_NAMESPACE_VERSION +} + namespace __gnu_debug { template @@ -144,7 +151,13 @@ namespace __gnu_debug __ptr == 0; } - /** We say that integral types for a valid range, and defer to other + template + _GLIBCXX_CONSTEXPR + inline bool + __check_singular(__gnu_cxx::__normal_iterator<_Tp*, _Cont> const& __x) + { return __x.base() == 0; } + + /** We say that integral types form a valid range, and defer to other * routines to realize what to do with integral types instead of * iterators. */