From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 13B14385842C; Wed, 7 Jun 2023 16:55:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 13B14385842C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686156957; bh=kavMk1202ufYN+M3IaSh2AI0VDs2jpKIy7KbaL200kk=; h=From:To:Subject:Date:From; b=UQdQcKFeLlun7LhMBw7slJeDu5sbbNpjjL0sdmS6Jhr4a2N1sxjGtRnfRN5Xr9ZEJ DUKFjiTNY2fpWHE22I6XgxEmPNIF2ay53u9mR5iU12xp77rf36bmwwaXe2BizWHkgq sNRL/Kh0ZS7kEVvdVM4YRDu1/D+CWN66WCXm6ai4= From: "danakj at orodu dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110160] New: g++ rejects concept as cyclical with non-matching function signature Date: Wed, 07 Jun 2023 16:55:56 +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: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: danakj at orodu dot net 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110160 Bug ID: 110160 Summary: g++ rejects concept as cyclical with non-matching function signature Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: danakj at orodu dot net Target Milestone: --- Godbolt: https://godbolt.org/z/d4PhfMqvq Code: ``` #include #include template concept StreamCanReceiveString =3D requires(T& t, std::string s) { { t << s }; }; struct NotAStream {}; struct UnrelatedType {}; template S& operator<<(S& s, UnrelatedType) { return s; } static_assert(!StreamCanReceiveString); static_assert(StreamCanReceiveString); ``` What happens here is GCC fails to be able to resolve the expression `StreamCanReceiveString`. 1. StreamCanReceiveString tries to do NotAStream << std::string. 2. There is a templated operator<< that takes `StreamCanReceiveString` and `UnrelatedType` 3. Since `UnrelatedType` is not std::string, this is not an overload candid= ate. 4. Clang and MSVC therefore do not try to recursively solve `StreamCanReceiveString` and reject the code. But GCC tries to solve the concept and then fails due to recursion.=