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]

Re: Partial ordering bug (?) in egcs



  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>'.  So, neither
version is more specialized.  Then, we just have to do overload
resolution.  The program is now equivalent to:

  class IndexPlaceholder {};
  class Array {};
  void max(const Array&, const IndexPlaceholder&);
  void max(const Array&, IndexPlaceholder);

  int main()
  {
    Array A;
    IndexPlaceholder j;
    max(A,j);
  }

EDG agrees with G++ that this program is ambiguous.

Thus, in short, I think G++ is correct in this case.

-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com


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