Partial ordering bug (?) in egcs

Thomas Kunert kunert@physik.tu-dresden.de
Tue Aug 11 00:06:00 GMT 1998


Mark Mitchell wrote:
> 
>   template<int N>
>   class IndexPlaceholder {
>   };
> 
>   template<class T, int N>
>   class Array {
>   };
> 
>   // #1
>   template<class T1, class T2>
>   void max(const T1& a, const T2& b)
>   {
>   }
> 
>   // #2
>   template<class T_numtype, int N_rank, int N_index>
>   inline void
>   max(const Array<T_numtype, N_rank>& array, IndexPlaceholder<N_index>)
>   {
>   }
> 
>   int main()
>   {
>       Array<int,2> A;
>       IndexPlaceholder<2> j;
>       max(A,j);                     // should match #2?
>   }
> 
> The first relevant question is: which is more specialized, #1 or #2?
> Certainly #1 is not more specialized than #2.  So, is #2 more
> specialized than #1?  But, equally certainly, #2 is not a
> specialization of #1, since there's no choice of `T2' that makes
> `const T2&' the same as `IndexPlaceholder<N_index>'.
              ^^^^^^^^^^^
    
Unfortunately I don't have a copy of the FDIS, but the Nov. 97 WP says
in 14.5.5.2 [temp.func.order]:

3 Using the transformed function parameter list, perform argument deduc-
  tion against the other function template.  The transformed template is
  at least as specialized as the other if, and only  if,  the  deduction
  succeeds  and  the  deduced parameter types are an exact match (so the
  deduction does not rely on implicit conversions).

`const T2&' is not supposed to be the the "same as" but an "exact match"
for
`IndexPlaceholder<N_index>'. 
In the example above you can choose an appropriate T2. 
Hence I think #2 is more specialized than #1.

--
Thomas Kunert



More information about the Gcc-bugs mailing list