This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/27162] New: search_n uses == when it should use binary_pred
- From: "doug dot gregor at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Apr 2006 17:02:24 -0000
- Subject: [Bug libstdc++/27162] New: search_n uses == when it should use binary_pred
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The binary predicate variant of search_n for forward iterators uses the "=="
operator where it should be calling __binary_pred. Patch (against GCC 4.1.0,
should also apply to the trunk) attached. Bug report courtest of ConceptGCC's
type checker :)
--- include/bits/stl_algo.h.old 2006-04-14 11:59:59.000000000 -0400
+++ include/bits/stl_algo.h 2006-04-14 12:00:08.000000000 -0400
@@ -748,7 +748,7 @@
__n = __count;
_ForwardIterator __i = __first;
++__i;
- while (__i != __last && __n != 1 && *__i == __val)
+ while (__i != __last && __n != 1 && __binary_pred(*__i, __val))
{
++__i;
--__n;
2006-04-14 Douglas Gregor <dgregor@cs.indiana.edu>
* include/bits/stl_algo.h (__search_n): Use __binary_pred, not ==.
--
Summary: search_n uses == when it should use binary_pred
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: doug dot gregor at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27162