In the following program we have two namespaces:
#include <iostream>
namespace B
{
int c = 42;
}
namespace A
{
using namespace B;
int a = 442;
}
namespace B
{
int b = 24;
}
int main()
{
std::cout << A::a << std::endl; //442
std::cout << A::b << std::endl; //24
std::cout << A::c << std::endl; //42
}
I thought the behavior of the program is being covered by N4296::3.3.6/1 [basic.scope.namespace]:
A namespace member name has namespace scope. Its potential scope includes its namespace from the name’s point of declaration (3.3.2) onwards; and for each using-directive (7.3.4) that nominates the member’s namespace, the member’s potential scope includes that portion of the potential scope of the using-directive that follows the member’s point of declaration.
So, in the case of the namespace A, the potential scope of the member b shouldn't have included any portion of the program, because the member was declared later then the using directive. But actually it can be found by qualified name lookup. What's wrong?