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]

Re: unqualified name lookup in namespace bug


> 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


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