This example results in an ambiguity on the line marked "!!!:

ex.c:8: error: ambiguous template specialization ‘to_y<char>’ for ‘Y<char,
void*, int> X::to_y()’

This is currently rejected by g++, MSVC, and EDG, but we (EDG) believe it
should be accepted.

14.8.2.4 says that in contexts other than a call, the complete function type
should be used for partial ordering purposes.



template<class T, class U, class V> struct Y { };

struct X {
  template<class T>          Y< T, void *, int> to_y();
  template<class T, class U> Y< T, U, int>      to_y();
};

template<> Y<char, void *, int>  X::to_y<char> ();        // !!!
template<> Y<char, int *, int>   X::to_y<char, int *> ();

void g() {
   X x;
   x.to_y<char> ();
   x.to_y<char, int *> ();
}


-- 
           Summary: Partial ordering of explicit specialization should
                    include return type
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jhs at edg dot com
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36435

Reply via email to