[Bug libstdc++/64903] is_partitioned should not apply a predicate more than (last - first) times
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Feb 2 16:24:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64903
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-02-02
Ever confirmed|0 |1
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I notice that libc++ has the same bug.
I think the problem is that we end up testing the partition point twice. Here's
a completely untested patch that avoids that:
--- a/libstdc++-v3/include/bits/stl_algo.h
+++ b/libstdc++-v3/include/bits/stl_algo.h
@@ -583,6 +583,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Predicate __pred)
{
__first = std::find_if_not(__first, __last, __pred);
+ if (__first == __last)
+ return true;
+ std::advance(__first, 1);
return std::none_of(__first, __last, __pred);
}
More information about the Gcc-bugs
mailing list