https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90276
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2024-01-24 00:00:00 |2019-04-29 0:00 --- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- In testsuite/util/pstl/test_utils.h we have: template <typename IsReverse> struct reverse_invoker { template <typename... Rest> void operator()(Rest&&... rest) { // Random-access iterator iterator_invoker<std::random_access_iterator_tag, IsReverse>()(std::forward<Rest>(rest)...); // Forward iterator iterator_invoker<std::forward_iterator_tag, IsReverse>()(std::forward<Rest>(rest)...); // Bidirectional iterator iterator_invoker<std::bidirectional_iterator_tag, IsReverse>()(std::forward<Rest>(rest)...); } }; This is called with rvalue iterators e.g. TestUtils::invoke_on_all_policies(check_minelement(), wseq.seq.cbegin(), wseq.seq.cend()); In the body of reverse_invoker::operator() we forward them as rvalues which causes them to be moved into the by-value parameters of iterator_invoker<random_access_iterator_tag, R>::operator() Then we forward them again, which causes them to be moved again. The debug iterators abort at this point, because they're singular after the first move. So the problem is that a moved-from __debug::vector::iterator is singular, and therefore can't be moved or copied. I wonder if that's really what we want, or if a moved-from iterator should have the value-initialized state instead of a singular state. The standard is clear that a singular iterator cannot be copied or moved, unless it was value-initialized, see [iterator.requirements.general] p7. In any case, the PSTL test harness should probably not be using moved-from iterators more than once.