https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119163
Bug ID: 119163 Summary: std::equal cannot be used with debug mode iterators in constant expressions Product: gcc Version: unknown Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- // { dg-do compile { target c++20 } } #define _GLIBCXX_DEBUG #include <vector> #include <algorithm> constexpr bool f() { std::vector<char> v; return std::equal(v.begin(), v.end(), v.begin(), v.end()); } static_assert( f() ); bits/stl_algobase.h:1717:7: error: call to non-'constexpr' function 'bool __gnu_debug::__valid_range(const _Safe_iterator<_Iterator, _Sequence, _Category>&, const _Safe_iterator<_Iterator, _Sequence, _Category>&) [with _Iterator = __gnu_cxx::__normal_iterator<char*, std::__cxx1998::vector<char, std::allocator<char> > >; _Sequence = std::__debug::vector<char>; _Category = std::random_access_iterator_tag]' 1717 | __glibcxx_requires_valid_range(__first1, __last1); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~