This is the mail archive of the gcc-help@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]

finding a function-template


The example below compiles succesfully with all gcc's pre 3.4, icc, xlC (IBM) but not with gcc-3.4.3. Is gcc-3.4.3 wrong or not? I guess the different behaviour of gcc-3.4.3 is because of the two-phase lookup, although xlC also has two-phase lookup.

This example compiles succesfully with gcc-3.4.3 if the definition of the function 'foo(B)' is moved before the definition of 'bar()'.


#include <iostream>


struct A {} ;
struct B {} ;

template <class T>
void foo(A) { std::cout << "foo(A)" << std::endl ; }

template <class T>
void bar() { foo< T >(B()) ; }

template <class T>
void foo(B) { std::cout << "foo(B)" << std::endl ; }

int main()
{
   bar< int >() ;
   return 0 ;
}


Thanks, toon


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