From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 97B6E3858D28; Mon, 6 Dec 2021 14:06:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 97B6E3858D28 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/65861] libstdc++ is silently generating wrong code when its std::search is given an input iterator Date: Mon, 06 Dec 2021 14:06:43 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 5.1.0 X-Bugzilla-Keywords: accepts-invalid X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Dec 2021 14:06:43 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D65861 --- Comment #12 from Jonathan Wakely --- (In reply to Jonathan Wakely from comment #9) > There are actually good reasons *not* to reject input iterators at > compile-time. >=20 > You could have an iterator which meets most, but not all, the forward > iterator requirements, and so must have input_iterator_tag as its categor= y. > Such as iterator could work fine with std::search, if we don't reject it = via > a static assertion. >=20 > (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 dete= ct > that as the only property we can test is the iterator_category tag). Since C++20 we can also check the iterator_concept tag. That means we can a= llow iterators that identify as input iterators according to iterator_category, = but forward iterators (or stronger) according to iterator_concept.=