This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
3.4 Bug? template dependent name lookup fails from template functions
- From: Michael Veksler <VEKSLER at il dot ibm dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 15 Apr 2004 13:58:16 +0300
- Subject: 3.4 Bug? template dependent name lookup fails from template functions
The following behavior of gcc looks wrong. I could not find anything in
the
standard that states otherwise. Just look at the following example and the
error that follows.
Am I right, and GCC contains a bug? If so, should I file a bug report
with target gcc-3.4.1 ?
$ cat t7.cc
void F(int) {}
void F(char) {}
template <class T> struct A {};
template <class T>
void F(const A<T> & )
{
T t;
F(t); // ok for T=double
::F( t ); // fails for T=double, does not find F(double)
}
void F(double) { } // This will be found, if moved before F<T>
int main()
{
A<double> a;
F(a); // shouldn't ::F(T) [for T=double] be looked up here?
}
$ $gcc34/bin/g++ -c t7.cc
t7.cc: In function `void F(const A<T>&) [with T = double]':
t7.cc:18: instantiated from here
t7.cc:11: error: call of overloaded `F(double&)' is ambiguous
t7.cc:1: note: candidates are: void F(int)
t7.cc:2: note: void F(char)
$ $gcc34/bin/g++ -v
Reading specs from
/home/veksler/gcc/lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Configured with: ../gcc-3.4.0-20040406/configure
--prefix=/home/veksler/gcc --enable-languages=c++
Thread model: posix
gcc version 3.4.0 20040407 (prerelease)
The :: operator is unavoidable when F is a template member function.
Also, I thought that '::F(T)' is a template dependent name that should
be looked up only during template instantiation.