From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B4E653861913; Fri, 16 Jul 2021 13:47:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4E653861913 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/101231] _CachedPosition::_M_get() should not return {} when range adapter does not model forward_range Date: Fri, 16 Jul 2021 13:47:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ppalka at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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: Fri, 16 Jul 2021 13:47:03 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101231 --- Comment #1 from CVS Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:1af937eb6246ad7f63ebff03590e9eede33aca81 commit r12-2357-g1af937eb6246ad7f63ebff03590e9eede33aca81 Author: Patrick Palka Date: Fri Jul 16 09:44:42 2021 -0400 libstdc++: invalid default init in _CachedPosition [PR101231] The primary template for _CachedPosition is a dummy implementation for non-forward ranges, the iterators for which generally can't be cached. Because this implementation doesn't actually cache anything, _M_has_val= ue is defined to be false and so calls to _M_get (which are always guarded by _M_has_value) are unreachable. Still, to suppress a "control reaches end of non-void function" warning I made _M_get return {}, but after P2325 input iterators are no longer necessarily default constructible so this workaround now breaks valid programs. This patch fixes this by instead using __builtin_unreachable to squelch the warning. PR libstdc++/101231 libstdc++-v3/ChangeLog: * include/std/ranges (_CachedPosition::_M_get): For non-forward ranges, just call __builtin_unreachable. * testsuite/std/ranges/istream_view.cc (test05): New test.=