This is the mail archive of the
mailing list for the GCC project.
unqualified name lookup in namespace bug
- To: egcs-bugs at cygnus dot com
- Subject: unqualified name lookup in namespace bug
- From: Nathan Sidwell <nathan at cs dot bris dot ac dot uk>
- Date: Mon, 03 Aug 1998 13:56:12 +0100
- Organization: Computer Science Dept, Bristol University
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
using namespace A;
using namespace B;
Here's the session log
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
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
email@example.com http://www.cs.bris.ac.uk/~nathan/ firstname.lastname@example.org