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

[Bug c++/17045] conflict between function template and class with same name


------- 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


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