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

template specialization bug


The 1996 draft standard says:

 14.5.4  Class template partial specializations       [temp.class.spec]
 
 ...
 
 5 Within  the  argument list of a class template partial specialization,
   the following restrictions apply:
 
   --A partially  specialized  non-type  argument  expression  shall  not
     involve a template parameter of the specialization.  [Example:
	       template <int I, int J> struct B {};
	       template <int I> struct B<I, I*2> {};  // error
      --end example]
 
   --The type of a specialized argument shall not be dependent on another
     parameter of the specialization.  [Example:
	       template <class T, T t> struct C {};
	       template <class T> struct C<T, 1>;  // error
      --end example]
 
   --The argument list of the specialization shall not  be  identical  to
     the implicit argument list of the primary template.


However, egcs (2.91.47 and 2.92.00) accepts these very examples (see
sample code below), even when compiled with "-ansi -pedantic -Wall
-Werror".

This is arguably a very useful extension to C++.  However, unless
things have changed since the 1996 draft, the code below should
probably be rejected when compiling with the -ansi flag.

Thanks,
David

==

template <int I, int J> struct B {};
template <int I> struct B<I, I*2> {};  // error

template <class T, T t> struct C {};
template <class T> struct C<T, 1>;  // error

B<2, 4> x;
C<int, 0> y;


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