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

RE: Possible gcc 3.4/4.0 bug wrt template dependant lookup


Please ignore this mail, I'm having trouble with my mail system at work, and this message is truncated. I'll attempt to send the correct version...

Andrew.

-----Original Message-----
From: Pollard, Andrew 
Sent: 16 November 2004 17:36
To: 'gcc@gcc.gnu.org'
Cc: Pollard, Andrew
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.


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