This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17045] conflict between function template and class with same name
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Aug 2004 14:53:14 -0000
- Subject: [Bug c++/17045] conflict between function template and class with same name
- References: <20040816030839.17045.gccbugs@contacts.eelis.net>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From bangerth at dealii dot org 2004-08-16 14:53 -------
What is really happening is that in the instantiation of ::f<N::f>, the
compiler sees the call
f(T());
Since the argument T() is of type N::f, it has to look up the name
of the function in both the global namespace and the namespace of
the argument, i.e. N (Koenig lookup). It just happens to find the
latter rather than the former.
An example that may be a little less confusing about reusing names is this:
---------------------
void h (...);
template <typename T> void g () { T t; h(t); }
namespace N
{
struct S {};
struct h;
}
void foo () { g<N::S>(); }
-----------------------
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc
x.cc: In function `void g() [with T = N::S]':
x.cc:11: instantiated from here
x.cc:8: error: `struct N::h' is not a function,
x.cc:1: error: conflict with `void h(...)'
x.cc:3: error: in call to `h'
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17045