This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/65861] libstdc++ is silently generating wrong code when its std::search is given an input iterator
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 02 May 2015 10:12:19 +0000
- Subject: [Bug libstdc++/65861] libstdc++ is silently generating wrong code when its std::search is given an input iterator
- Auto-submitted: auto-generated
- References: <bug-65861-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65861
--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> ---
There are actually good reasons *not* to reject input iterators at
compile-time.
You could have an iterator which meets most, but not all, the forward iterator
requirements, and so must have input_iterator_tag as its category. Such as
iterator could work fine with std::search, if we don't reject it via a static
assertion.
(istreambuf_iterator is not such an iterator, as it's genuinely a single-pass
iterator, and so can't be used ... but we can't reliably detect that as the
only property we can test is the iterator_category tag).