This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Fix PR c++/27582: ICE with invalid template parameter


The C++ frontend ICEs on the following invalid code snippet:

  struct A
  {
    template<int> void foo();
  };

  template<int N, void (A::*)() = &A::foo<N> > struct B {};

  B<int> b;

bug.cc:8: error: type/value mismatch at argument 1 in template parameter list for 'template<int N, void (A::* <anonymous>)()> struct B'
bug.cc:8: error:   expected a constant of type 'int', got 'int'
bug.cc:8: internal compiler error: tree check: expected tree_vec, have error_mark in any_dependent_template_arguments_p, at cp/pt.c:12751
Please submit a full bug report, [etc.]

Apparently, any_dependent_template_arguments_p cannot handle error_mark_nodes
as argument.

The following patch fixes that by adding an appropriate check.

Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for mainline, 4.1 branch, and 4.0 branch?

Regards,
Volker

:ADDPATCH C++:


2006-05-12  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/???
	* pt.c (any_dependent_template_arguments_p): Return early on invalid
	argument list.

===================================================================
--- gcc/gcc/cp/pt.c	(revision 113720)
+++ gcc/gcc/cp/pt.c	(working copy)
@@ -12758,6 +12758,8 @@ any_dependent_template_arguments_p (tree args)
 
   if (!args)
     return false;
+  if (args == error_mark_node)
+    return true;
 
   for (i = 0; i < TMPL_ARGS_DEPTH (args); ++i)
     {
===================================================================

2006-05-12  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/???
	* g++.dg/template/dependent-args1.C: New test.

===================================================================
--- gcc/gcc/testsuite/g++.dg/template/dependent-args1.C	2005-08-29 00:25:44 +0200
+++ gcc/gcc/testsuite/g++.dg/template/dependent-args1.C	2006-05-12 17:36:43 +0200
@@ -0,0 +1,11 @@
+// PR c++/???
+// { dg-do compile }
+
+struct A
+{
+  template<int> void foo();
+};
+
+template<int N, void (A::*)() = &A::foo<N> > struct B {};
+
+B<int> b; // { dg-error "type/value mismatch|expected a constant|invalid type" }
===================================================================



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]