GCC and Clang are right. In Foo::tester unqualified use of Bar clearly refers to Foo::Bar .
An unqualified search is given by C ++ 11 3.4.1 / 1:
to search for areas, a declaration is used in the order indicated in each of the corresponding categories; the name search ends as soon as an ad is found for the name.
The areas used to use a name in a function are listed in section 3.4.1 / 6:
The name used in the definition of the function [...], which is a member of the namespace N [...], must be declared before its use in the block [...] or must be declared before its use in the namespace N or, if N is a nested namespace, must be declared before it is used in one of the Ns spanning namespaces.
In this case, the function is a member of Foo , so the search for Foo is performed before the enclosing (global) namespace, which includes the unnamed namespace. Foo::Bar is there, and the search ends.
source share