From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 654793858C5E; Thu, 9 Mar 2023 18:25:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 654793858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678386354; bh=uHQOzTjfIhdM/c7ptnPGGWFg53Ud+Dc8Grq55i6NEVE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NKFcYhlf8LazsTn/Y6WQ8XG8xkmhCew3idnNJ66moNHsF6Dke0Kx8fN8lFmpsqYUv 3zpLeKoLHbtJu36cCSIVPMBCwdhBAmx66prGEOuSFzDTFPwJ7RZow0sHpiQpBIeiMX EH+C0eQagc066RtMcshscVN3JoEboqojUzCqEhY8= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/107572] cartesian_product_view invokes the begin of input_range twice Date: Thu, 09 Mar 2023 18:25:53 +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: 13.0 X-Bugzilla-Keywords: wrong-code 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107572 --- Comment #1 from CVS Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:3df9760d56662bdf38dd45f7398f003bbd64fdfe commit r13-6558-g3df9760d56662bdf38dd45f7398f003bbd64fdfe Author: Patrick Palka Date: Thu Mar 9 13:25:44 2023 -0500 libstdc++: extraneous begin in cartesian_product_view::end [PR107572] ranges::begin() isn't guaranteed to be equality-preserving for non-forw= ard ranges, so in cartesian_product_view::end we need to avoid needlessly calling begin() on the first range (which could be non-forward) in the case where __empty_tail is false as per its specification. Since we're already using a variadic lambda to compute __empty_tail, we might as well use that same lambda to build up the tuple of iterators instead of building it separately via e.g. std::apply or __tuple_transf= orm. PR libstdc++/107572 libstdc++-v3/ChangeLog: * include/std/ranges (cartesian_product_view::end): When building the tuple of iterators, avoid calling ranges::begin on the first range if __empty_tail is false. * testsuite/std/ranges/cartesian_product/1.cc (test07): New tes= t.=