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 <ch...@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

Reply via email to