This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Possible gcc 3.4/4.0 bug wrt template dependant lookup
- From: "Pollard, Andrew" <andrew dot pollard at brooks dot com>
- To: <gcc at gcc dot gnu dot org>
- Cc: "Pollard, Andrew" <andrew dot pollard at brooks dot com>
- Date: Tue, 16 Nov 2004 18:35:53 +0100
- Subject: Possible gcc 3.4/4.0 bug wrt template dependant lookup
The program in question is
?
foo.cxx:
------------------------------------
template<typename T> int foo(const T&)????? { return (1);????????? }
template<typename T> struct M { int bar()?? { return (::foo(T())); } };
template<typename T> struct S { int bar()?? { return (T(0));?????? } };
template<typename T> int foo(const S<T>& s) { return (s.bar());??? }
?
int
main()
{
??? M<S<int> > q;
??? return (q.bar());
}
------------------------------------
?
% g++34 foo.cxx; ./a.out; echo $?
1
% g++40 foo.cxx; ./a.out; echo $?
1
% g++33 foo.cxx; ./a.out; echo $?
0
?
If I change line 2 to be
?
template<typename T> struct M { int bar()?? { return (foo(T())); } };
?
ie, remove the :: qualification on foo, it returns 0.
?
Also, if I move the 'struct M' to after the foo() specialization for S<T>,
it also returns 0 (with or without the :: qualification)
?
It is as if the :: qualification is stopping the bar() method being template
type dependent, and binding the call at parse time and not at instantiation
time (in this case, getting the base template for foo() and not the specialization)
?
What, if anything, am I missing?
?
Thanks,
?Andrew.