From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 39284396DC0F; Tue, 31 May 2022 18:39:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 39284396DC0F 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: Tue, 31 May 2022 18:39:45 +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: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: ppalka at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.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: Tue, 31 May 2022 18:39:46 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101231 --- Comment #4 from CVS Commits --- The releases/gcc-10 branch has been updated by Patrick Palka : https://gcc.gnu.org/g:656cd10436260de997f5202b6737c7b8aebdfb4f commit r10-10809-g656cd10436260de997f5202b6737c7b8aebdfb4f 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++/103904 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. (cherry picked from commit 1af937eb6246ad7f63ebff03590e9eede33aca81)=