This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

nth_element fix [58800]


A previous fix to a performance problem in std::sort unfortunately has
lead to a crashing bug in std::nth_element.

The following minimal patch fixes the problem (there are a couple of
different ways of fixing it, this is the shortest and safest).

2013-09-19 Chris Jefferson <chris@bubblescope.net>

PR libstdc++/58800
* include/bits/stl_algo.h (__unguarded_partition_pivot) : Change
__last - 2 to __last - 1, so we correctly work on arrays of length 4.
* testsuite/25_algorithms/nth_element/58800.cc : New

Attachment: nth_element1.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]