[Bug libstdc++/58800] [4.8 regression, I think] std::nth_element segfaults on valid input
paolo.carlini at oracle dot com
gcc-bugzilla@gcc.gnu.org
Fri Oct 18 23:53:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58800
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Don't tell me is just this:
Index: include/bits/stl_algo.h
===================================================================
--- include/bits/stl_algo.h (revision 203835)
+++ include/bits/stl_algo.h (working copy)
@@ -1917,7 +1917,7 @@
_RandomAccessIterator __last, _Compare __comp)
{
_RandomAccessIterator __mid = __first + (__last - __first) / 2;
- std::__move_median_to_first(__first, __first + 1, __mid, (__last - 2),
+ std::__move_median_to_first(__first, __first + 1, __mid, (__last - 1),
__comp);
return std::__unguarded_partition(__first + 1, __last, __first, __comp);
}
??
Andy, while waiting for Chris' feedback, you may want to test the above on your
real applications. In 4.8.x some nth_algorithm details are different (the above
is versus mainline), but you can quickly find a couple of (__last - 2) which
I'm asking you to change to (__last - 1)
More information about the Gcc-bugs
mailing list