From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 070AA3858D29; Mon, 15 Mar 2021 13:24:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 070AA3858D29 From: "the_gamester28 at msn dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/99599] New: Concepts requirement falsely reporting recursion, breaks tag_invoke pattern Date: Mon, 15 Mar 2021 13:24:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: the_gamester28 at msn dot com 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: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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: Mon, 15 Mar 2021 13:24:11 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99599 Bug ID: 99599 Summary: Concepts requirement falsely reporting recursion, breaks tag_invoke pattern Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: the_gamester28 at msn dot com Target Milestone: --- The following code compiles fine on GCC 10, Clang, MSVC, but fails in GCC 11/trunk: ### begin struct foo_tag{}; struct bar_tag{}; template concept fooable =3D requires(T it) { invoke_tag(foo_tag{}, it); // <-- here }; template auto invoke_tag(foo_tag, T in) { return in; } template auto invoke_tag(bar_tag, T it) { return it; } int main() { // Neither line below compiles in GCC 11, independently of the other return invoke_tag(foo_tag{}, 2); return invoke_tag(bar_tag{}, 2); } ### end Produces the following compiler error: ### begin : In substitution of 'template requires fooable auto invoke_tag(bar_tag, T) [with T =3D int]': :6:15: required by substitution of 'template requires=20 fooable auto invoke_tag(bar_tag, T) [with T =3D int]' :21:35: required from here :5:9: required for the satisfaction of 'fooable' [with T =3D i= nt] :5:19: in requirements with 'T it' [with T =3D int] :5:19: error: satisfaction of atomic constraint 'requires(T it) {invoke_tag({}, it);} [with T =3D T]' depends on itself 5 | concept fooable =3D requires(T it) { | ^~~~~~~~~~~~~~~~ 6 | invoke_tag(foo_tag{}, it); | ~~~~~~~~~~~~~~~~~~~~~~~~~~ 7 | }; | ~=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ### end It seems that the template requirements of invoke_tag(bar_tag, int) are considered while evaluating line marked "here". Requirements of irrelevant overloads should not be considered, as it can potentially lead to falsely reporting a cyclic dependency. This bug effectively prevents using the modern tag_invoke pattern, which is increasingly used as a customisation point in many modern libraries.=