This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Possible gcc 3.4/4.0 bug wrt template dependant lookup
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: "Pollard, Andrew" <andrew dot pollard at brooks dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 16 Nov 2004 17:50:46 +0000
- Subject: Re: Possible gcc 3.4/4.0 bug wrt template dependant lookup
- Organization: Codesourcery LLC
- References: <B0EF51D84DDEEF4D9F7D485485751F6C075EA3@mail-brooks5.brooks.com>
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