public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/84015, ICE with class deduction and auto template parm
@ 2018-02-26  5:02 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2018-02-26  5:02 UTC (permalink / raw)
  To: gcc-patches List

[-- 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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-02-26  5:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-26  5:02 C++ PATCH for c++/84015, ICE with class deduction and auto template parm Jason Merrill

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).