From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 734E33857C52; Thu, 13 May 2021 03:04:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 734E33857C52 From: "ppalka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/100577] [11/12 Regression] Unhelpful diagnostics for ill-formed call to partially applied range adaptor object Date: Thu, 13 May 2021 03:04:40 +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: 11.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: ppalka at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.2 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: Thu, 13 May 2021 03:04:40 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100577 --- Comment #2 from Patrick Palka --- Some context: the purpose of this deleted operator() is so that when invoki= ng an adaptor object as an rvalue, we don't ever select the const&-qualified operator() overload, because doing so would break the perfect forwarding ca= ll wrapper semantics required of partially applied adaptor objects and pipelin= es, and cause us to silently accept the P2281 example 'x | views::split(non_view_range)' (forming a split_view containing a dangling reference). This deleted const&&-qualified overload always wins over the const&-qualified overload in the rvalue case, and so prevents this breakage from happening. This PR arguably calls for an improvement on the frontend side -- the diagnostic for when overload resolution chooses a deleted function could al= so perhaps explain why the other candidates weren't selected. But I think we can also work around this deficiency on the library side by essentially disabling the perfect forwarding call wrapper machinery for ran= ge adaptors that don't need it, which currently is all of them except for views::split. For the other adaptors, we could get away with just a single overload for _Partial::operator() and _Pipe::operator().=