From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 07B5B385E01D; Sat, 28 Mar 2020 12:59:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 07B5B385E01D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1585400356; bh=PQT5va6A0YbfE4MC2jyw4LhBu9adTPVa3dThGm9aMFo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fQuoYPQesZnoBfMcKPS4ALDkQjcUWhx/Y3JxA+Wyk4ob7wEq6CpQgAomFnP/uW4vL hoNEIrgYGYoGQUOwggbXXWRAtVEOT04bBhZS8LhawFFKGWuJ3QNKtnyDkI+r0rDY1D 2XpmBwmcckx1WGtaWJ4q0ENzKURm62LAGamCSUtM= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/94252] Can't use a lambda in a requires expression Date: Sat, 28 Mar 2020 12:59:15 +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: 10.0 X-Bugzilla-Keywords: rejects-valid 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: 10.0 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: Sat, 28 Mar 2020 12:59:16 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94252 --- Comment #3 from CVS Commits --- The master branch has been updated by Patrick Palka : https://gcc.gnu.org/g:a7ea3d2ced786c4544fa625f34f515d89ed074fe commit r10-7441-ga7ea3d2ced786c4544fa625f34f515d89ed074fe Author: Patrick Palka Date: Sat Mar 28 08:56:59 2020 -0400 c++: requires-expression outside of a template is misevaluated [PR94252] This PR shows that a REQUIRES_EXPR outside of a template can sometimes = be misevaluated. This happens because the evaluation routine tsubst_requires_expr (and diagnose_requires_expr) assumes the REQUIRES_EXPR's subtrees are templated trees and that therefore it's safe to call tsubst_expr on them. But th= is assumption isn't valid when we've parsed a REQUIRES_EXPR outside of a template context. In order to make this assumption valid here, this patch sets processing_template_decl to non-zero before parsing the body of a REQUIRES_EXPR so that its subtrees are indeed always templated trees. gcc/cp/ChangeLog: PR c++/94252 * constraint.cc (tsubst_compound_requirement): Always suppress errors from type_deducible_p and expression_convertible_p, as they're = not substitution errors. (diagnose_atomic_constraint) : Remove this ca= se so that we diagnose INTEGER_CST expressions of non-bool type via t= he default case. * cp-gimplify.c (cp_genericize_r) : New cas= e. * parser.c (cp_parser_requires_expression): Always parse the requirement body as if we're processing a template, by temporarily incremen= ting processing_template_decl. Afterwards, if we're not actually in= a template context, perform semantic processing to diagnose any invalid types and expressions. * pt.c (tsubst_copy_and_build) : Remove dead code. * semantics.c (finish_static_assert): Explain an assertion fail= ure when the condition is a REQUIRES_EXPR like we do when it is a concept check. gcc/testsuite/ChangeLog: PR c++/94252 * g++.dg/concepts/diagnostic7.C: New test. * g++.dg/concepts/pr94252.C: New test. * g++.dg/cpp2a/concepts-requires18.C: Adjust to expect an additional diagnostic.=