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++/11338] New: Function template overload resolution failure


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

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

           Summary: Function template overload resolution failure
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mstaley at lanl dot gov
                CC: gcc-bugs at gcc dot gnu dot org

(I tried to enter this bug report into Bugzilla yesterday, but it apparently
didn't get entered. This is the first time I've used Bugzilla, and I apologize
in advance if this bug gets entered twice.)

The following code does not compile with g++ 3.3, or with g++ 3.4 (with the new
parser, right?), which my sysadmin installed from the CVS repository on June 25.
I'm running on a Linux box with Red Hat 9.

     #include <iostream>

     template<int n>
     class bar {
     };

     template<class T>
     T fun(const bar<1> &)
     {
        std::cout << "fun #1" << std::endl;
        return T();
     }

     template<class T, class BAR>
     T fun(const BAR &)
     {
        std::cout << "fun #2" << std::endl;
        return T();
     }

     int main(void)
     {
        fun<double>(bar<1>());  // isn't fun #1 the better match?
        fun<double>(bar<2>());
     }

My take is that this is legal C++, with "fun #1" being the better match for the
first call in the body of main(). G++ says this call is ambiguous. Incidentally,
the Intel C++ compiler also reported an error; however, Metrowerks C++ and KAI
C++ (the latter of which in my experience is usually correct) DID compile this
code.

Okay, what's the verdict?


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