public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "iains at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-96251-4-3kQ71wY7hF@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96251-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96251

--- Comment #4 from Iain Sandoe <iains at gcc dot gnu.org> ---
So, as noted, the problem is being caused because the coroutine is being
regarded as potentially constexpr while still type-dependent, and then failing
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-circuit
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_rval,
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:

===

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 that
some way of punting in template expansion is needed (or the initial check needs
to be less conservative).

  parent reply	other threads:[~2021-02-16  8:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-20 14:40 [Bug c++/96251] New: " yuri.kilochek at gmail dot com
2020-07-20 14:41 ` [Bug c++/96251] " yuri.kilochek at gmail dot com
2020-07-20 14:43 ` yuri.kilochek at gmail dot com
2020-07-21 18:53 ` iains at gcc dot gnu.org
2021-02-16  8:35 ` iains at gcc dot gnu.org [this message]
2021-02-16 20:45 ` [Bug c++/96251] [constexpr, coroutines] " iains at gcc dot gnu.org
2021-02-16 20:58 ` iains at gcc dot gnu.org
2021-02-22 21:04 ` iains at gcc dot gnu.org
2021-02-24 11:57 ` cvs-commit at gcc dot gnu.org
2021-02-24 11:58 ` iains at gcc dot gnu.org
2021-03-21 23:52 ` cvs-commit at gcc dot gnu.org
2021-03-22  0:02 ` iains at gcc dot gnu.org
2021-08-28 22:08 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-96251-4-3kQ71wY7hF@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).