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]
Other format: [Raw text]

[Bug c++/11752] New: partial ordering overloaded function templates


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: partial ordering overloaded function templates
           Product: gcc
           Version: 3.2.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: nbecker at fred dot net
                CC: gcc-bugs at gcc dot gnu dot org

In the following example, I believe the call should not be ambiguous, because 
the second overloaded Rnd function is more specialized, and partial ordering 
should apply: 
 
template<int shift, int size, typename T> 
inline T Rnd (T x) { 
  T y = x >> (shift - 1); 
  if (y == Sint<size+1>::max) 
    return y >> 1; 
  else 
    return (y + 1) >> 1; 
} 
 
template<int shift, int size, typename FLT> 
inline std::complex<FLT> Rnd (std::complex<FLT> x) { 
  return std::complex<FLT> (Rnd<size, shift, FLT> (real (x)), Rnd<size, shift, 
FLT> (imag (x))); 
} 
 
../Test/Test6.cc:224: call of overloaded `Rnd(std::complex<int>)' is ambiguous 
../src/fixed/FixedUtil.H:18: candidates are: T Rnd(T) [with int shift = 6, int  
   size = 8, T = std::complex<int>] 
../src/fixed/FixedUtil.H:27:                 std::complex<FLT>  
   Rnd(std::complex<FLT>) [with int shift = 6, int size = 8, FLT = int] 
gcc -v 
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs 
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man 
--infodir=/usr/share/info --enable-shared --enable-threads=posix 
--disable-checking --with-system-zlib --enable-__cxa_atexit 
--host=i386-redhat-linux 
Thread model: posix 
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)


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