[Bug c++/40256] New: Explicit function template call doesn't trigger Koenig lookup when it should

rodolfo at rodsoft dot org gcc-bugzilla@gcc.gnu.org
Tue May 26 11:36:00 GMT 2009


14.8.1/6 says:

"But when a function template with explicit template arguments is used, the
call does not have the correct syntactic form unless there is a function
template with that name visible at the point of the call. If no such name is
visible, the call is not syntactically well-formed and argument-dependent
lookup does not apply. If some such name is visible, argument dependent lookup
applies and additional  function templates may be found in other namespaces."

Then the following example is given, which doesn't compile on GCC-4.3.3:

namespace A {
        struct B { };
        template<int X> void f(B);
}
namespace C {
        template<class T> void f(T t);
}
void g(A::B b) {
        // stripping out ill-formed cases

        using C::f;
        f<3>(b);                // well-formed because C::f is visible; then
                                // A::f is found by argument dependent lookup
}

g++ doesn't compile it, stating:

teste.cpp: In function 'void g(A::B)':
teste.cpp:12: error: no matching function for call to 'f(A::B&)'

I haven't tested with 4.4, nor have found a similar bug.


-- 
           Summary: Explicit function template call doesn't trigger Koenig
                    lookup when it should
           Product: gcc
           Version: 4.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rodolfo at rodsoft dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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



More information about the Gcc-bugs mailing list