https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90105
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- I think this is the fix: --- a/libstdc++-v3/include/bits/forward_list.tcc +++ b/libstdc++-v3/include/bits/forward_list.tcc @@ -469,9 +469,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER __p = static_cast<_Node*>(__p->_M_next); --__psize; } - else if (__comp(*__p->_M_valptr(), *__q->_M_valptr())) + else if (!__comp(*__q->_M_valptr(), *__p->_M_valptr())) { - // First node of p is lower; e must come from p. + // First node of q is not lower; e must come from p. __e = __p; __p = static_cast<_Node*>(__p->_M_next); --__psize;