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]

partial ordering problem?


// the code below produces the following error when compiled with 

//Reading specs from /usr/local/gcc-2.95.2/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/specs
//gcc version 2.95.2 19991024 (release)
 
//tmpl_ref_array_ovld.cc: In function `int main()':
//tmpl_ref_array_ovld.cc:10: call of overloaded `f (int[1])' is ambiguous
//tmpl_ref_array_ovld.cc:3: candidates are: void f<int[1]>(int (&)[1])
//  tmpl_ref_array_ovld.cc:6:                 void f<int>(int *)

// I think that the code should compile and that the template fct with 
// the pointer argument should be selected --- there is no ambiguity: 
// According to 14.8.2.1 argument deduction should lead to the forms 
// void f( int (&)[1] ) and void f( int * ) for the viable functions for which 
// overload resolution is attempted (this seems to be ok, as those are the 
// signatures of the functions in the error message.

// according to 13.3.3.1.4-1 the required conversion on the argument of the 
// the call to  void f( int (&)[1] ) is the identity conversion, which 
// is neither better nor worse (13.3.3.2-3) than the array-to-pointer 
// conversion sequence necessary in the call to void f( int * ).

// However, since the T* version of the template function is more specialized 
// then the T & version, then according to 13.3.3 (1), the T* version must 
// be selected.  

// Am I missing something? 

// Stefan Schwarzer                                sts@ica1.uni-stuttgart.de

template<class T>
void f(T &){}

template<class T>
void f( T* ){}

int main(){
  int d[] ={2};
  f(d);
  return 0;
}






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