]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR libstdc++/90105 make forward_list::sort stable
authorJonathan Wakely <jwakely@redhat.com>
Wed, 8 May 2019 12:17:26 +0000 (13:17 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 8 May 2019 12:17:26 +0000 (13:17 +0100)
commita2fb1fb666a10dae17c5bde5ec877cbfe02d08c8
tree883960258dd0d127d37e1f833641cbd1f86ab240
parent67bfe1e90ebb1216941481f978540927f98e25f1
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  <jwakely@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.

From-SVN: r271010
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/forward_list.tcc
libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc
libstdc++-v3/testsuite/23_containers/forward_list/operations/90105.cc [new file with mode: 0644]