From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DE1383850415; Tue, 16 Feb 2021 08:35:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE1383850415 From: "iains at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/96251] co_yield incorrectly rejected in non-explicitly-constexpr generic lambda Date: Tue, 16 Feb 2021 08:35:54 +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.1.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: iains at gcc dot gnu.org X-Bugzilla-Status: NEW 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: 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: Tue, 16 Feb 2021 08:35:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96251 --- Comment #4 from Iain Sandoe --- So, as noted, the problem is being caused because the coroutine is being regarded as potentially constexpr while still type-dependent, and then fail= ing during template expansion. All the coroutine expressions are correctly marked as not suitable for constexpr. One can also use the DECL_COROUTINE_P on the function decl (which is added = as soon as any coroutine keyword is encountered - that would perhaps short-cir= cuit some work), but it doesn't fix the bug. ... like so. diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 377fe322ee8..c4226599072 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -7827,6 +7827,9 @@ potential_constant_expression_1 (tree t, bool want_rv= al, bool strict, bool now, switch (TREE_CODE (t)) { case FUNCTION_DECL: + if (DECL_COROUTINE_P (t)) + return false; + /* FALLTHROUGH. */ case BASELINK: case TEMPLATE_DECL: case OVERLOAD: =3D=3D=3D The for loop body is never visited during the initial parse, but rather the dependent type in the loop init expression causes a conservative early exit (with a 'true' result). It seems that this conservative approach to potentially-constexpr, means th= at some way of punting in template expansion is needed (or the initial check n= eeds to be less conservative).=