PATCH for Re: Full specialization
Mark Mitchell
mmitchell@usa.net
Fri Mar 20 12:40:00 GMT 1998
Kurt --
Here's a patch for the crash you got on a bogus partial
specialization. Jason?
--
Mark Mitchell <mmitchell@usa.net>
http://home.earthlink.net/~mbmitchell
Consulting Services Available
Fri Mar 20 12:35:31 1998 Mark Mitchell <mmitchell@usa.net>
* pt.c (push_template_decl): Don't crash when presented with
invalid partial specializations.
Index: cp/pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.101
diff -c -p -r1.101 pt.c
*** pt.c 1998/03/20 10:44:05 1.101
--- pt.c 1998/03/20 20:32:07
*************** push_template_decl (decl)
*** 1530,1535 ****
--- 1530,1543 ----
tree mainargs = CLASSTYPE_TI_ARGS (type);
tree spec = DECL_TEMPLATE_SPECIALIZATIONS (maintmpl);
+ if (TREE_VEC_LENGTH (mainargs) +
+ TREE_VEC_LENGTH (TREE_VALUE (current_template_parms)) >=
+ TREE_VEC_LENGTH (DECL_INNERMOST_TEMPLATE_PARMS (maintmpl)))
+ {
+ cp_error ("too many template parameters in declaration of");
+ cp_error ("partial specialization `%T'", type);
+ }
+
for (; spec; spec = TREE_CHAIN (spec))
{
/* purpose: args to main template
Index: testsuite/g++.old-deja/g++.pt/crash4.C
===================================================================
RCS file: crash4.C
diff -N crash4.C
*** /dev/null Mon Dec 31 20:00:00 1979
--- crash4.C Fri Mar 20 12:32:07 1998
***************
*** 0 ****
--- 1,12 ----
+ // Build don't link:
+
+ template <unsigned rank>
+ class Tensor
+ {
+ };
+
+ template <unsigned rank>
+ class Tensor<2> : Tensor<rank> // ERROR - too many template parameters
+ {
+ };
+
More information about the Gcc-bugs
mailing list