From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 83944385D0E0; Fri, 28 Oct 2022 14:01:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 83944385D0E0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666965709; bh=MSpClXtMoAyERKgEpnmUKKRUSSomJrTWJNmqdBDW28I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=CHbKvJnprYOweIQj2TDWH5THtK9Woms4LTIw2ZpTQos3Eh/Jz8JGVAoVPt9jPEUXA 5g+wG5pFLB/j21KgtgAq07ja/JkloGtTE+BtZM214nL91wz0UsuRian42FiJ70C4DA tb1qMWU415Zn0O5AHGG9m4YAr3Ub4xW1tjDNvssM= From: "ppalka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107439] use of static member function in requires-expression depends on declaration order Date: Fri, 28 Oct 2022 14:01:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: rejects-valid 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: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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=3D107439 Patrick Palka changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ppalka at gcc dot gnu.org --- Comment #1 from Patrick Palka --- > This seems inconsistent, as member functions are normally expected to be = usable anywhere within the class definition. IIUC associated constraints are part of the function signature and thus are= n't late parsed like the function body is, so later-declared members aren't generally usable in a constraint. Interestingly, if we add a dummy argument to 'check' then we accept the call (and treat it as an ADL-enabled call to an unknown function template where unqualified lookup found nothing): struct A { template requires (check(0)) auto func(T) { } template static consteval bool check(0) { return true; } }; But if we then try to actually use func, its constraint will always fail du= e to 'check' not being visible at the point of use (since associated constraints aren't late-parsed): int main() { A a; a.func(0); // error: =E2=80=98check=E2=80=99 was not declared in this sco= pe, and no declarations were found by argument-dependent lookup at the point of instantiation } This behavior (for the modified testcase) is correct AFAICT (Clang behaves = the same).=