From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ABEC63858287; Tue, 28 Nov 2023 18:22:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABEC63858287 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701195728; bh=QkHiFmFipmmKDajtHZbbBvcZy6DBvSrpBJDtFQzasr0=; h=From:To:Subject:Date:From; b=YH02BrtngL73ebVAb01U3Jw9Sc2rd1v9KAMAod7vV3+RQ0jO0iiCjOz4ZyiW5TEKw /iiRDqR2guEdTZEfEkK+3Fej4y8zCT61J4YWXMY7Kz8cpyLY1EEJsKoPUHCAknU6cM ilA9iGSUjo89o5b5ZSGysI3MtxRUnI2Rak05ZUmw= From: "novulae at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/112749] New: GCC accepts invalid code in concepts (requires clause incorrectly satisfied) Date: Tue, 28 Nov 2023 18:22:08 +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: 13.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: novulae at hotmail 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112749 Bug ID: 112749 Summary: GCC accepts invalid code in concepts (requires clause incorrectly satisfied) Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: novulae at hotmail dot com Target Milestone: --- The below example is ill-formed - the requires clause should not be satisfi= ed due to the failure to instantiate W1, but GCC accepts the code nonetheless. Clang rejects the code. $ cat gcc-bug.cpp template concept C1 =3D true; template using W1 =3D decltype(nonexistent(0)); template requires C1> void func(T); void test() { func(0); } $ g++ -c -std=3Dc++20 gcc-bug.cpp $ clang++ -c -std=3Dc++20 gcc-bug.cpp gcc-bug.cpp:10:3: error: no matching function for call to 'func' 10 | func(0); | ^~~~ gcc-bug.cpp:7:6: note: candidate template ignored: constraints not satisfied [with T =3D int] 7 | void func(T); | ^ gcc-bug.cpp:3:39: note: because substituted constraint expression is ill-formed: use of undeclared identifier 'nonexistent' 3 | template using W1 =3D decltype(nonexistent(0)); | ^ 1 error generated.=