public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ppalka at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/94645] [10 Regression][concepts] incorrect concept evaluation with decltype, plus internal error since r10-7554-gf1ad7bac76b66257
Date: Tue, 21 Apr 2020 23:21:21 +0000	[thread overview]
Message-ID: <bug-94645-4-t1lKxPOaIn@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94645-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #9 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Thanks for the reduced testcases.


The problem in #c8 seems to start in grokfndecl() when processing the
operator() of the lambda.  During grokfndecl on the operator(),
processing_template_decl is 1 but template_class_depth is 0 (seems it should be
1 here?).  So the condition for 'memtmpl' in

      tree ctx = friendp ? current_class_type : ctype;
      bool memtmpl = (processing_template_decl > template_class_depth (ctx));

is true for this non-templated lambda, but IIUC 'memtmpl' should be true only
if the declaration in question has its own set of template parameters, which is
not the case here.

Since memtmpl is true, we then attach the innermost constraints (belonging to
struct l) to this non-templated operator() via:

      if (memtmpl)
        tmpl_reqs = TEMPLATE_PARMS_CONSTRAINTS (current_template_parms);
      tree ci = build_constraints (tmpl_reqs, decl_reqs);
      ...
      set_constraints (decl, ci);

and thing goes downhill from there.


I tried fixing template_class_depth to return 1 in this case via

--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -390,7 +390,12 @@ template_class_depth (tree type)
        ++depth;

       if (DECL_P (type))
-       type = CP_DECL_CONTEXT (type);
+       {
+         if (tree fctx = DECL_FRIEND_CONTEXT (type))
+           type = fctx;
+         else
+           type = CP_DECL_CONTEXT (type);
+       }
       else if (LAMBDA_TYPE_P (type) && LAMBDA_TYPE_EXTRA_SCOPE (type))
        type = LAMBDA_TYPE_EXTRA_SCOPE (type);
       else

but this change causes a bunch of ICEs in the cmcstl2 testsuite.

It seems that the condition for 'memtmpl' needs adjusting, but I'm not sure
how.

  parent reply	other threads:[~2020-04-21 23:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-18  4:22 [Bug c++/94645] New: incorrect concecpt evaluation with decltype, plus internal erropr avi@cloudius-systems.com
2020-04-18  4:26 ` [Bug c++/94645] " avi@cloudius-systems.com
2020-04-19 21:58 ` [Bug c++/94645] incorrect concept " rafael at espindo dot la
2020-04-20  6:58 ` [Bug c++/94645] [10 Regression][concepts] incorrect concept evaluation with decltype, plus internal error rguenth at gcc dot gnu.org
2020-04-20  7:28 ` marxin at gcc dot gnu.org
2020-04-20  9:04 ` avi@cloudius-systems.com
2020-04-20  9:19 ` [Bug c++/94645] [10 Regression][concepts] incorrect concept evaluation with decltype, plus internal error since r10-7554-gf1ad7bac76b66257 marxin at gcc dot gnu.org
2020-04-20  9:19 ` marxin at gcc dot gnu.org
2020-04-21 12:52 ` ppalka at gcc dot gnu.org
2020-04-21 12:54 ` ppalka at gcc dot gnu.org
2020-04-21 15:17 ` ppalka at gcc dot gnu.org
2020-04-21 19:08 ` rafael at espindo dot la
2020-04-21 23:21 ` ppalka at gcc dot gnu.org [this message]
2020-04-23  4:38 ` jason at gcc dot gnu.org
2020-04-23 13:15 ` ppalka at gcc dot gnu.org
2020-04-23 21:42 ` cvs-commit at gcc dot gnu.org
2020-04-23 21:42 ` ppalka at gcc dot gnu.org
2020-04-23 23:43 ` rafael at espindo dot la

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-94645-4-t1lKxPOaIn@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).