https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90105
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> --- Author: redi Date: Wed May 8 12:17:26 2019 New Revision: 271010 URL: https://gcc.gnu.org/viewcvs?rev=271010&root=gcc&view=rev Log: PR libstdc++/90105 make forward_list::sort stable While testing the fix I also discovered that operator== assumes the elements are comparable with operator!= which is not required. Backport from mainline 2019-04-17 Jonathan Wakely <jwak...@redhat.com> PR libstdc++/90105 * include/bits/forward_list.tcc (operator==): Do not use operator!= to compare elements. (forward_list<T, A>::sort(Comp)): When elements are equal take the one earlier in the list, so that sort is stable. * testsuite/23_containers/forward_list/operations/90105.cc: New test. * testsuite/23_containers/forward_list/comparable.cc: Test with types that meet the minimum EqualityComparable and LessThanComparable requirements. Remove irrelevant comment. Added: branches/gcc-7-branch/libstdc++-v3/testsuite/23_containers/forward_list/operations/90105.cc - copied, changed from r271009, branches/gcc-7-branch/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc Modified: branches/gcc-7-branch/libstdc++-v3/ChangeLog branches/gcc-7-branch/libstdc++-v3/include/bits/forward_list.tcc branches/gcc-7-branch/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc