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

unqualified name lookup in namespace bug

I think this is a bug with egcs, but I'm using the dec 96 draft standard
as a reference and it doesn't (appear to) give an explicit example of
what I think should happen. References I give in the trailing discussion
are to this version of the standard.

I'm using the 1998-07-27 snapshot. Here's the program
--begin uqlookup.ii
namespace A
  void f(int);

namespace B
  using namespace A;
  void f();
  void h();

using namespace B;

void g()

void B::h()
--end uqlookup.ii

Here's the session log
--begin log
nathan@laie:5215>uname -a                       
SunOS laie 5.5.1 Generic sun4u sparc SUNW,Ultra-1
nathan@laie:5216>egcs-0727-g++ -v -c uqlookup.ii
Reading specs from
gcc version egcs-2.91.52 19980727 (gcc2 ss-980609 experimental)

uqlookup.ii -quiet -version -o /var/tmp/cclbRUxc.s
GNU C++ version egcs-2.91.52 19980727 (gcc2 ss-980609 experimental)
(sparc-sun-solaris2.5.1) compiled by GNU C version 2.8.1.
uqlookup.ii: In function `void h()':
uqlookup.ii:9: too many arguments to function `f()'
uqlookup.ii:24: at this point in file
--end log

I think ::g and B::h should have the same behaviour. I.e. both A::f(int)
and B::f() are available for overload resolution in the calls to f() and

In ::g, we are in the global namespace. This contains a using directive
for namespace B, hence all the names in B are available. Unqualified
name lookup searches B and finds B::f(). But also, because B contains a
using directive for namespace A, we also consider names inside A, and
hence find A::f(int). para 2 of 3.4.1 `Unqualified name look up' appears
to support this `... declarations from the namespace nominated by the
using directive are considered members of that enclosing namespace.' As
we've found (at least one) instance of the name we were looking for,
name lookup terminates. para 1 of 3.4.1 tells us to terminate `...
scopes are searcg ... in the order listed ... name lookup ends as soon
as a declaration is found for the name'. Overload resolution then goes
on to select f() or f(int).

In B::h() we are in namespace B, and hence unqualified name lookup
commences there (after searching the local scope of B::h). In B we find
B::f(). It seems to me that the using directive is also visible, and
hence namespace A should also be searched, before terminating the

Is my understanding correct (and hence a bug), or am I missing

Dr Nathan Sidwell :: Computer Science Department :: Bristol University
      You can up the bandwidth, but you can't up the speed of light

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