unqualified name lookup in namespace bug
Martin von Loewis
martin@mira.isdn.cs.tu-berlin.de
Mon Aug 3 23:57:00 GMT 1998
> Is my understanding correct (and hence a bug), or am I missing
> something?
The latter :-), in particular the 'common ancestor' feature. From
[namespace.udir]/2
>>During unqualified name lookup (3.4.1), the names appear as if they
>>were declared in the nearest enclosing namespace which contains both
>>the usingÃÂdirective and the nominated namespace.
So when looking for f in B, A::f appears as if it was declared in ::
(which is the nearest enclosing namespace that contains both A and B).
Therefore, unqualified lookup searches B, finds B::f, and terminates.
When looking up in ::g, the nearest enclosing scope is always ::, so
all names found via using-directives appear as if in ::, which gives
you both A::f and B::f.
If you want to merge the A::f variants into B::f, a using directive is
the way to go.
Hope this helps,
Martin
More information about the Gcc-bugs
mailing list