This is the mail archive of the 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]

Fix PR c++/18962: use arg list from definition, not declaration

The testcase in the bug report follows:

template<class T1,int N1>
class Class
    template <class T2,int N2> void function( const Class<T2,N2>& );

template<class T2,int N2>
void Class<int,1>::function( const Class<T2,N2>& param ) 
    param;// line 12

int main()
    Class<int,1> instance;
    Class<char,2> param;
    instance.function( param );

It illustrates a problem in the current code: in a definition of a
template specialization, we disregard the (function, not template)
argument list given in the definition, and use the argument list from
the original declaration, because determine_specialization() builds a
new tmpl out of the original declarations, without paying attention to
the argument list in the decl built out of the declarator parsed for
the definition.

Taking the arg list from the decl fixes the problem the testcase
above, but I can't tell upfront whether this could have any ill
effects.  Could someone more familiar with this code please review
this patch?  I'm regression-testing it on x86_64-linux-gnu now, ok to
install along with the testcase if it passes?

Index: gcc/cp/ChangeLog
from  Alexandre Oliva  <>

	PR c++/18962
	* pt.c (check_explicit_specialization): Use the argument list from
	the definition in a template function specialization definition.

Index: gcc/cp/pt.c
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.959
diff -u -p -r1.959 pt.c
--- gcc/cp/pt.c 16 Dec 2004 11:03:32 -0000 1.959
+++ gcc/cp/pt.c 22 Dec 2004 07:40:57 -0000
@@ -2051,6 +2051,10 @@ check_explicit_specialization (tree decl
 		    = DECL_SOURCE_LOCATION (decl);
+		  /* We want to use the argument list specified in the
+		     definition, not in the original declaration.  */
+		    = DECL_ARGUMENTS (decl);
 	      return tmpl;
Alexandre Oliva   
Red Hat Compiler Engineer   aoliva@{,}
Free Software Evangelist  oliva@{,}

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