https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86658
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2018-07-24 Known to work| |8.1.0 Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org Target Milestone|--- |9.0 Summary|Debug mode: std::copy(..., |[9 Regression] Debug mode: |std::inserter(...)) causes |std::copy(..., |"Error: attempt to |std::inserter(...)) causes |copy-construct an iterator |"Error: attempt to |from a singular iterator." |copy-construct an iterator | |from a singular iterator." Ever confirmed|0 |1 Known to fail| |9.0 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- The problem is that __niter_wrap takes its argument by value, and in this case that makes a copy of the output iterator after it's been invalidated. I'll test this fix: --- a/libstdc++-v3/include/bits/stl_algobase.h +++ b/libstdc++-v3/include/bits/stl_algobase.h @@ -288,7 +288,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // No need to wrap, iterator already has the right type. template<typename _Iterator> inline _Iterator - __niter_wrap(_Iterator, _Iterator __res) + __niter_wrap(const _Iterator&, _Iterator __res) { return __res; } // All of these auxiliary structs serve two purposes. (1) Replace