public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++/59759 - ICE in unify, using std::enable_if on classes
@ 2016-01-19 18:09 Martin Sebor
  2016-01-20 13:39 ` Jason Merrill
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Sebor @ 2016-01-19 18:09 UTC (permalink / raw)
  To: Gcc Patch List, ktietz70, Marek Polacek, Jason Merrill

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

Attached is the patch to avoid the ICE that Kai posted below
with the test case Marek asked for in his response.  I didn't
see any further followup on the list.

   https://gcc.gnu.org/ml/gcc-patches/2015-05/msg02325.html

Martin

[-- Attachment #2: gcc-59759.patch --]
[-- Type: text/x-patch, Size: 1847 bytes --]

gcc/testsuite/ChangeLog:
2016-01-19  Martin Sebor  <msebor@redhat.com>

	PR c++/59759
	* gcc/testsuite/g++.dg/template/pr59759.C: New test.

gcc/cp/ChangeLog:
2015-05-26  Kai Tietz  <ktietz70@googlemail.com>

	PR c++/69277
	* pt.c (unify): Don't ICE on VAR_DECL.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 6062ebe..3361796 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -19928,11 +19928,11 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
       return unify_template_argument_mismatch (explain_p, parm, arg);
 
     case VAR_DECL:
-      /* A non-type template parameter that is a variable should be a
+      /* A non-type template parameter that is a variable should be
 	 an integral constant, in which case, it whould have been
-	 folded into its (constant) value. So we should not be getting
-	 a variable here.  */
-      gcc_unreachable ();
+	 folded into its (constant) value.  So we should not see
+	 a variable here except for ill-formed programs.  */
+      return unify_template_argument_mismatch (explain_p, parm, arg);
 
     case TYPE_ARGUMENT_PACK:
     case NONTYPE_ARGUMENT_PACK:
diff --git a/gcc/testsuite/g++.dg/template/pr59759.C b/gcc/testsuite/g++.dg/template/pr59759.C
new file mode 100644
index 0000000..c6a0b04
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/pr59759.C
@@ -0,0 +1,23 @@
+// PR c++/59759 - internal compiler error: in unify, using std::enable_if
+//                on classes
+// { dg-do compile }
+
+template <class T>
+struct B { };
+
+template <class, class T>
+struct C {
+  typedef T U;
+};
+
+const int x = 0;
+
+// The default argument below is invalid for A<int>.
+template <class T, class C<B<T>, int>::U = x>
+struct A;
+
+template <class T>
+void f (A<T>*) {
+  A<int>* map;   // { dg-error "not a class type" }
+  f (map);       // { dg-error "no matching function" }
+}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] c++/59759 - ICE in unify, using std::enable_if on classes
  2016-01-19 18:09 [PATCH] c++/59759 - ICE in unify, using std::enable_if on classes Martin Sebor
@ 2016-01-20 13:39 ` Jason Merrill
  2016-01-20 16:47   ` Martin Sebor
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Merrill @ 2016-01-20 13:39 UTC (permalink / raw)
  To: Martin Sebor, Gcc Patch List, ktietz70, Marek Polacek

On 01/19/2016 01:09 PM, Martin Sebor wrote:
> Attached is the patch to avoid the ICE that Kai posted below
> with the test case Marek asked for in his response.  I didn't
> see any further followup on the list.

Thanks, but the code is actually well-formed; I've now fixed the bug 
properly.

Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] c++/59759 - ICE in unify, using std::enable_if on classes
  2016-01-20 13:39 ` Jason Merrill
@ 2016-01-20 16:47   ` Martin Sebor
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Sebor @ 2016-01-20 16:47 UTC (permalink / raw)
  To: Jason Merrill, Gcc Patch List, ktietz70, Marek Polacek

On 01/20/2016 06:39 AM, Jason Merrill wrote:
> On 01/19/2016 01:09 PM, Martin Sebor wrote:
>> Attached is the patch to avoid the ICE that Kai posted below
>> with the test case Marek asked for in his response.  I didn't
>> see any further followup on the list.
>
> Thanks, but the code is actually well-formed; I've now fixed the bug
> properly.

You're right.  I had reduced the test case some more (comment #15)
and inadvertently made it ill-formed in the process by replacing
'typename' with 'class' in the definition of A, while still
triggering the ICE.   Your patch does the right thing with both.

Martin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-01-20 16:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-19 18:09 [PATCH] c++/59759 - ICE in unify, using std::enable_if on classes Martin Sebor
2016-01-20 13:39 ` Jason Merrill
2016-01-20 16:47   ` Martin Sebor

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