This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
finding a function-template
- From: Toon Knapen <toon dot knapen at fft dot be>
- To: gcc-help at gcc dot gnu dot org
- Cc: Karl Meerbergen <karl dot meerbergen at fft dot be>
- Date: Mon, 07 Feb 2005 18:38:50 +0100
- Subject: 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