https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78830
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |INVALID Target Milestone|--- |10.0 --- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> --- I don't think it's conforming to reject this at compile-time, because std::prev(it, -1) is equivalent to std::advance(it, 1) which is valid for forward iterators. So libc++ has a bug, it is not allowed to reject forward iterators unconditionally (only when it can prove the argument to prev is greater than zero). The best we can do is check for negative values at runtime and abort, which we already do. One day I hope to be able to enhance those assertions to warn at compile-time if the compiler can tell the assertion will fail, but that is not currently possible.