]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Fix regression in std::stable_sort
authorJonathan Wakely <jwakely@redhat.com>
Wed, 24 Aug 2022 12:53:27 +0000 (13:53 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 24 Aug 2022 14:22:44 +0000 (15:22 +0100)
commit530f80451a9e76896a0294e0f4bd59baff1ac27f
treee8fea123ff26374a51fa5ed4a907f16072df79d9
parent0b7c9254998b3fb2c39f6b86b5b196f415530205
libstdc++: Fix regression in std::stable_sort

The recent change to split out the cold path of std::stable_sort caused
a regression for some Qt code. The problem is that the library now adds
a value of type ptrdiff_t to the iterator, which is ambiguous with
-pedantic. The addition could either convert the iterator to a built-in
pointer and add the ptrdiff_t to that, or it could convert the ptrdiff_t
to the iterator's difference_type and use the iterator's own operator+.

The fix is to cast the ptrdiff_t value to the difference type first.

libstdc++-v3/ChangeLog:

* include/bits/stl_algo.h (__stable_sort): Cast size to
iterator's difference type.
* testsuite/25_algorithms/stable_sort/4.cc: New test.
libstdc++-v3/include/bits/stl_algo.h
libstdc++-v3/testsuite/25_algorithms/stable_sort/4.cc [new file with mode: 0644]
This page took 0.07891 seconds and 6 git commands to generate.