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


Pollard, Andrew wrote:
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()); }

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)

correct. ::foo is bound at parse time to those foo's visible at the point of definition. That's ::foo(const T&). This gets instantiated when M<T>::bar gets instantiated. The other ::foo, ::foo(const S<T>&) is a different overload, (it's not a partial specialization, 'cos there are no such things as function partial specializations).

[14.6] has the details

nathan

--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@codesourcery.com    ::     http://www.planetfall.pwp.blueyonder.co.uk



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