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++/95468] [8/9/10/11 Regression] ICE in expression sfinae
Date: Wed, 03 Jun 2020 15:48:06 +0000	[thread overview]
Message-ID: <bug-95468-4-HD08jPah6I@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-95468-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
The reason we fail to compile the testcase when 'condition' is at class scope
instead of at namespace scope is because in the former case, the template
argument 'c::condition<bool(true)>' is a CALL_EXPR to a BASELINK, and when
doing instantiate_non_dependent_expr_internal on this CALL_EXPR, we don't
semantically process the template argument 'bool(true)' within BASELINK because
we never call tsubst_baselink because tsubst_copy exits early when args is
NULL_TREE.

We don't have this problem in the latter case where 'condition' is at namespace
scope, because then the template argument 'condition<bool(true)>' is a
CALL_EXPR to a TEMPLATE_ID_EXPR, and TEMPLATE_ID_EXPRs are handled directly
from tsubst_copy_and_build which doesn't do an early exit when args is
NULL_TREE.

A potential untested fix therefore is to also handle BASELINK directly from
tsubst_copy_and_build:

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c                                          
index d7f61289621..e15fca54823 100644                                           
--- a/gcc/cp/pt.c                                                               
+++ b/gcc/cp/pt.c                                                               
@@ -19472,6 +19472,11 @@ tsubst_copy_and_build (tree t,                         
     case SCOPE_REF:                                                            
       RETURN (tsubst_qualified_id (t, args, complain, in_decl, /*done=*/true,  
                                  /*address_p=*/false));                        
+                                                                               
+    case BASELINK:                                                             
+      RETURN (tsubst_baselink (t, current_nonlambda_class_type (),             
+                              args, complain, in_decl));                       
+                                                                               
     case ARRAY_REF:                                                            
       op1 = tsubst_non_call_postfix_expression (TREE_OPERAND (t, 0),           
                                                args, complain, in_decl);       

Ideally we might want two versions of tsubst_baselink, one that does template
argument substitution and another than additionally performs semantic
processing?

  parent reply	other threads:[~2020-06-03 15:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-01 19:57 [Bug c++/95468] New: " kab at acm dot org
2020-06-02  5:56 ` [Bug c++/95468] " marxin at gcc dot gnu.org
2020-06-03  1:09 ` kab at acm dot org
2020-06-03 15:23 ` [Bug c++/95468] [8/9/10/11 Regression] " ppalka at gcc dot gnu.org
2020-06-03 15:48 ` ppalka at gcc dot gnu.org [this message]
2021-01-14  8:57 ` rguenth at gcc dot gnu.org
2021-02-12 23:37 ` ppalka at gcc dot gnu.org
2021-02-23 14:40 ` cvs-commit at gcc dot gnu.org
2021-02-23 14:42 ` [Bug c++/95468] [8/9/10 " ppalka at gcc dot gnu.org
2021-03-31 12:33 ` cvs-commit at gcc dot gnu.org
2021-04-21 21:09 ` [Bug c++/95468] [8/9 " cvs-commit at gcc dot gnu.org
2021-05-14 13:58 ` [Bug c++/95468] [8 " jakub 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-95468-4-HD08jPah6I@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).