From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 1C6233858CDB for ; Thu, 20 Jul 2023 16:00:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1C6233858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689868830; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=DSd9OT2wPKMFRA/OQlF4ZQAlWxs1iwmV/S0NBg44rJc=; b=X5Ageh1B8eMPBnKMlRtbhUvY2o7IgE18J2KgBkTIuBV0Up1Q4xGYDKm+YAr8hf9isZikmK ljZtHBhRpOUEU43zGrnr6SQDDUeMcqkWDETbc1Jbzm4fQTHJtuMJVxXyiq+wDXT4DO9VNX 9BGxACsqAUehQBwvS0cMJHFQn4OWeqw= Received: from mail-ua1-f70.google.com (mail-ua1-f70.google.com [209.85.222.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-461-La5CnHgLPcuyaDHjk-Zbcg-1; Thu, 20 Jul 2023 12:00:18 -0400 X-MC-Unique: La5CnHgLPcuyaDHjk-Zbcg-1 Received: by mail-ua1-f70.google.com with SMTP id a1e0cc1a2514c-7919ce40684so144582241.0 for ; Thu, 20 Jul 2023 09:00:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689868806; x=1690473606; h=mime-version:references:message-id:in-reply-to:subject:cc:to:date :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DSd9OT2wPKMFRA/OQlF4ZQAlWxs1iwmV/S0NBg44rJc=; b=jtDPtlAJD0V5AJShi3R0wMxu8SBSNuQMUJPi6XlOu0UBMpAktnP/pSBbgKYeLNgcCx 0YzLaoWE4d3ybiPKQWX0R+A1Dd6+ks7Rwj5ILZ9DET1Gy7VHNvC8LNfpgBYsJCmbW7DR PzSwLJTIEOssyQhb2IEqg89gqQa42JZwnrXBZY/IizLgwmkazdcN2gq4TiP2ag9tYh/W LDyEssRY/Ib9QuEyf4avGlbMuK+4nhisYbBpoY3rzOUOezE/hDqSqLe+w5XCWC2VDFO5 4rbtyc3+mKabhDTRMnn+3RtRIA0S1Yiduw9ew80YTN8KPa0tB2Qs5IO2symEPVoRHGmY 7bPA== X-Gm-Message-State: ABy/qLY0dsHN7JgU56ucYDydEHVJRvVpW/1GIdb29qZ/3TFnGL3L5TCq qInjlLW8di9PRFZ0yBaVB9gJXli5064DIGsENtJyF1sXo+SH9/lOH+XLzuBi5bW5rlEs0F2Hzmr LlClq8iU2okE7TLntPA== X-Received: by 2002:a05:6102:34f4:b0:445:20ba:fb16 with SMTP id bi20-20020a05610234f400b0044520bafb16mr2555729vsb.25.1689868806087; Thu, 20 Jul 2023 09:00:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlF5BazMBsFOx4vnGqAAbRLNi0oaU48jKQ+C8je2qI4Mu6jOiV9+8aXUOh5qUQfu/q0WMqc/tA== X-Received: by 2002:a05:6102:34f4:b0:445:20ba:fb16 with SMTP id bi20-20020a05610234f400b0044520bafb16mr2555721vsb.25.1689868805794; Thu, 20 Jul 2023 09:00:05 -0700 (PDT) Received: from [192.168.1.130] (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id x15-20020a0c8e8f000000b0061b5dbf1994sm472590qvb.146.2023.07.20.09.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jul 2023 09:00:05 -0700 (PDT) From: Patrick Palka X-Google-Original-From: Patrick Palka Date: Thu, 20 Jul 2023 12:00:04 -0400 (EDT) To: Jason Merrill cc: Patrick Palka , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] c++: passing partially inst tmpl as ttp [PR110566] In-Reply-To: <3693e80f-15a9-b20b-a3f0-242395b1d101@redhat.com> Message-ID: References: <20230719180536.2447863-1-ppalka@redhat.com> <3693e80f-15a9-b20b-a3f0-242395b1d101@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, 19 Jul 2023, Jason Merrill wrote: > On 7/19/23 14:05, Patrick Palka wrote: > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > > trunk/13? > > > > -- >8 -- > > > > Since the arguments 'pargs' passed to the coerce_template_parms from > > coerce_template_template_parms are always a full set, we need to make sure > > we always pass the parameters of the most general template because if the > > template is partially instantiated then the levels won't match up. > > Hmm, so then my comment "In that case we might end up adding more levels than > needed, but that shouldn't be a problem; any args we need to refer to are at > the right level." is wrong for auto template parms? I suppose, but only for the ttp case I think? It seems all is well when passing an ordinary template as a ttp as long as we use the parameters of the most general template for the coercion. I can't come up with a counterexample at least. > > So I guess we likely need to do more to assure that pargs has the right number > of levels if there are autos in the innermost arg parms. > > Also, most_general_template doesn't work for TTPs, so that probably won't help > handle their partial instantiations. Ah, yeah :( Here's an analagous testcase that we still ICE on due to this: template class> struct A; template struct B { template struct C { template class TT> using type = A; }; }; template struct B::C; I think I have a fix using get_innermost_template_args. > > And is it right for an alias template in a partial specialization? IIUC yes, e.g. tsubst directly relies on most_general_template to work for alias templates (when substituting an alias template specialization). > > > In the > > testcase below during said call to coerce_template_parms the parameters > > are {X, Y} both level 1, but the arguments are {{int}, {N, M}}, which > > leads to a crash during auto deduction of X and Y. > > > > PR c++/110566 > > Since this is a regression from the patch for PR c++/108179, please list that > PR here as well, to help avoid backporting that patch without this one. > > > gcc/cp/ChangeLog: > > > > * pt.cc (coerce_template_template_parms): Simplify by using > > DECL_INNERMOST_TEMPLATE_PARMS and removing redundant asserts. > > Always pass the parameters of the most general template to > > coerce_template_parms. > > > > gcc/testsuite/ChangeLog: > > > > * g++.dg/template/ttp38.C: New test. > > --- > > gcc/cp/pt.cc | 12 +++++------- > > gcc/testsuite/g++.dg/template/ttp38.C | 12 ++++++++++++ > > 2 files changed, 17 insertions(+), 7 deletions(-) > > create mode 100644 gcc/testsuite/g++.dg/template/ttp38.C > > > > diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc > > index d882e9dd117..8723868823e 100644 > > --- a/gcc/cp/pt.cc > > +++ b/gcc/cp/pt.cc > > @@ -8073,12 +8073,10 @@ coerce_template_template_parms (tree parm_tmpl, > > tree parm, arg; > > int variadic_p = 0; > > - tree parm_parms = INNERMOST_TEMPLATE_PARMS (DECL_TEMPLATE_PARMS > > (parm_tmpl)); > > - tree arg_parms_full = DECL_TEMPLATE_PARMS (arg_tmpl); > > - tree arg_parms = INNERMOST_TEMPLATE_PARMS (arg_parms_full); > > - > > - gcc_assert (TREE_CODE (parm_parms) == TREE_VEC); > > - gcc_assert (TREE_CODE (arg_parms) == TREE_VEC); > > + tree parm_parms = DECL_INNERMOST_TEMPLATE_PARMS (parm_tmpl); > > + tree arg_parms = DECL_INNERMOST_TEMPLATE_PARMS (arg_tmpl); > > + tree gen_arg_tmpl = most_general_template (arg_tmpl); > > + tree gen_arg_parms = DECL_INNERMOST_TEMPLATE_PARMS (gen_arg_tmpl); > > nparms = TREE_VEC_LENGTH (parm_parms); > > nargs = TREE_VEC_LENGTH (arg_parms); > > @@ -8134,7 +8132,7 @@ coerce_template_template_parms (tree parm_tmpl, > > scope_args = TI_ARGS (tinfo); > > pargs = add_to_template_args (scope_args, pargs); > > - pargs = coerce_template_parms (arg_parms, pargs, NULL_TREE, > > tf_none); > > + pargs = coerce_template_parms (gen_arg_parms, pargs, NULL_TREE, > > tf_none); > > if (pargs != error_mark_node) > > { > > tree targs = make_tree_vec (nargs); > > diff --git a/gcc/testsuite/g++.dg/template/ttp38.C > > b/gcc/testsuite/g++.dg/template/ttp38.C > > new file mode 100644 > > index 00000000000..7d25d291e81 > > --- /dev/null > > +++ b/gcc/testsuite/g++.dg/template/ttp38.C > > @@ -0,0 +1,12 @@ > > +// PR c++/110566 > > +// { dg-do compile { target c++20 } } > > + > > +template class> > > +struct A; > > + > > +template > > +struct B { > > + template struct C; > > +}; > > + > > +using type = A::C>; > >