[PATCH] PR libstdc++/90105 make forward_list::sort stable

Jonathan Wakely jwakely@redhat.com
Thu Apr 18 02:38:00 GMT 2019

On 16/04/19 23:16 +0100, Jonathan Wakely wrote:
>While testing the fix I also discovered that operator== assumes the
>elements are comparable with operator!= which is not required.
>	PR libstdc++/90105
>	* include/bits/forward_list.h (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.
>Tested powerpc64le-linux.
>I'm surprised nobody has noticed either of these bugs before! I think
>this is safe for stage 4, and for backporting to active branches. Any

Committed to trunk.

More information about the Gcc-patches mailing list