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]

koenig lookup in C++



After looking at the C standard, I think that
g++.old-deja/g++.ns/koenig7.C is legal C++, and so this patch must be
wrong:

2000-08-11  Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr>

	* decl2.c (add_function): Reorganize.
	(arg_assoc): Do not consider function template decls.

A simplified verson of the test looks like this:

namespace N1 {
  struct A { };
  void f2(float) {}
  void g(void (*)(float)) {}
}

using N1::f2;
template <class T>
void f2(N1::A, T) {}

void g(void (*)(int)) {}

int main() {  
   g(f2); // Works?
}

I believe this should work, because the argument
types of the g(f2) function are:

void f2(float)
template <class T> void f2(N1::A, T)

both of these are function types.  For function types, the associated
namespaces are those associated with their parameter and return
types.  For the first function type, there are no associated
types as all the parameters/return values are fundamental types.  For
the second set of function types, namespace N1 is associated because
one of the parameters is of type N1::A, a structure type in N1, which
has N1 associated with it.

Thus g can be either the g in the default namespace or the g in N1;
and then the only one that matches is the g in N1, and the parameter
must be N1::f2.

Does this sound right?  I'm no C++ language lawyer, I just play one on
TV :-).  If so, I'd appreciate it if someone could either (a) revert
the patch, (b) fix it, or (c) mark the testcase as XFAIL.  Otherwise
the testcase is wrong, which should be easy enough to fix.

-- 
- Geoffrey Keating <geoffk@cygnus.com>

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