From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 654B93888411; Thu, 10 Jun 2021 21:29:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 654B93888411 From: "cvs-commit 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, 10 Jun 2021 21:29:47 +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: 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: 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, 10 Jun 2021 21:29:48 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100577 --- Comment #5 from CVS Commits --- The releases/gcc-11 branch has been updated by Patrick Palka : https://gcc.gnu.org/g:80495610eb8c3b1395073cebd26a079d81b73403 commit r11-8547-g80495610eb8c3b1395073cebd26a079d81b73403 Author: Patrick Palka Date: Thu Jun 3 09:49:30 2021 -0400 libstdc++: Simplify range adaptors' forwarding of bound args [PR100577] r11-8053 rewrote the range adaptor implementation in conformance with P2281R1, making partial application act like a SFINAE-friendly perfect forwarding call wrapper. Making SFINAE-friendliness coexist with perfect forwarding here requires adding fallback deleted operator() overloads (as described in e.g. section 5.5 of P0847R6). But unfortunately, as reported in PR100577, this necessary technique of using of deleted overloads regresses diagnostics for ill-formed calls to partially applied range adaptors in GCC. Although GCC's diagnostics can arguably be improved here by having the compiler explain why the other candidates weren't viable when overload resolution selects a deleted candidate, we can also largely work around this on the library side (and achieve more concise diagnostics than by a frontend-side improvement alone) if we take advantage of the observation that not all range adaptors need perfect forwarding call wrapper semantics, in fact only views::split currently needs it, because all other range adaptors either take no extra arguments or only arguments that are expected to be freely/cheaply copyable, e.g. function objects and integer-like types. (The discussion section in P2281R1 goes into detail about why views::split is special.) To that end, this introduces opt-in flags for denoting a range adaptor as having "simple" extra arguments (in the case of a range adaptor non-closure) or having a "simple" call operator (in the case of a range adaptor closure). These flags are then used to conditionally simplify the operator() for the generic _Partial and _Pipe class templates, down from needing three overloads thereof (including one defined as deleted) to just needing a single overload. The end result is that diagnostic quality is restored for all adaptors except for views::split, and diagnostics for the adaptors are generally made more concise since there's only a single _Partial/_Pipe overload to diagnose instead of three of them. libstdc++-v3/ChangeLog: PR libstdc++/100577 * include/std/ranges (_RangeAdaptorClosure): Document _S_has_simple_call_op mechanism. (_RangeAdaptor): Document _S_has_simple_extra_args mechanism. (__closure_has_simple_call_op): New concept. (__adaptor_has_simple_extra_args): Likewise. (_Partial<_Adaptor, _Args...>): New partial specialization. (_Partial<_Adaptor, _Arg>): Likewise. (_Pipe<_Lhs, _Rhs>): Likewise. (views::_All::_S_has_simple_call_op): Define to true. (views::_Filter::_S_has_simple_extra_args): Likewise. (views::_Transform::_S_has_simple_extra_args): Likewise. (views::_Take::_S_has_simple_extra_args): Likewise. (views::_TakeWhile::_S_has_simple_extra_args): Likewise. (views::_Drop::_S_has_simple_extra_args): Likewise. (views::_DropWhile::_S_has_simple_extra_args): Likewise. (views::_Join::_S_has_simple_call_op): Likewise. (views::_Split): Document why we don't define _S_has_simple_extra_args to true for this adaptor. (views::_Common::_S_has_simple_call_op): Define to true. (views::_Reverse::_S_has_simple_call_op): Likewise. (views::_Elements::_S_has_simple_call_op): Likewise. * testsuite/std/ranges/adaptors/100577.cc: New test. (cherry picked from commit 57ed620ebfa4275d04efeec973e88f506b0e3ba8)=