public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: C++ PATCH for c++/84015, ICE with class deduction and auto template parm
Date: Mon, 26 Feb 2018 05:02:00 -0000	[thread overview]
Message-ID: <CADzB+2=dvGq5P79_oQTjAQhx2hrfeWHYu8P5-zQ_Fu9vNBs+Jw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 437 bytes --]

While rewriting the template parameters of a member template
constructor to generate the corresponding deduction guide, we tsubst
the parms twice.  In this bug, on the first pass we ended up lowering
the level of the 'auto' TEMPLATE_TYPE_PARM to 1, so the second pass
blows up.  This is very similar to the situation that I already
introduced tf_partial for, so let's use it here as well.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 84015.diff --]
[-- Type: text/plain, Size: 1276 bytes --]

commit 2b7c1f2a66551ce9462c82d119820b524a83b28e
Author: Jason Merrill <jason@redhat.com>
Date:   Sun Feb 25 21:50:15 2018 -0500

            PR c++/84015 - ICE with class deduction and auto template parm.
    
            * pt.c (rewrite_template_parm): Use tf_partial in first tsubst.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 85d1adbbe3c..9cf96e9fbe4 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -25596,7 +25596,7 @@ rewrite_template_parm (tree olddecl, unsigned index, unsigned level,
 	  // Substitute ttargs into ttparms to fix references to
 	  // other template parameters.
 	  ttparms = tsubst_template_parms_level (ttparms, ttargs,
-						 complain);
+						 complain|tf_partial);
 	  // Now substitute again with args based on tparms, to reduce
 	  // the level of the ttparms.
 	  ttargs = current_template_args ();
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction49.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction49.C
new file mode 100644
index 00000000000..086f12ad3c6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction49.C
@@ -0,0 +1,15 @@
+// PR c++/84015
+// { dg-additional-options -std=c++17 }
+
+template <int I>
+struct A { };
+
+template <int I>
+struct B
+{
+  template<template<auto>class T>
+  B(T<I>);
+};
+
+A<42> a;
+B b (a);

                 reply	other threads:[~2018-02-26  5:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='CADzB+2=dvGq5P79_oQTjAQhx2hrfeWHYu8P5-zQ_Fu9vNBs+Jw@mail.gmail.com' \
    --to=jason@redhat.com \
    --cc=gcc-patches@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).