https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100990
Bug ID: 100990 Summary: Iterator checks for Debug Mode cannot be used with a non-common range Product: gcc Version: 11.1.1 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- The Debug Mode iterator checks assume two iterators of the same type, so do not work with an iterator and a sentinel. It should be possible to use std::common_iterator like so: __glibcxx_require_valid_range(common_iterator<_It, _Sent>(__it), common_iterator<_It, _Sent>(__sent)); But wrapping a _Safe_iterator in common_iterator will prevent the checks from making use of the additional information present in a _Safe_iterator (and maybe prevent other checks from matching the iterator type?) It would be nice to be able to use those debug mode assertions in ranges algos and ranges::advance etc.