Well-formed.
The using-directive doesn't introduce the name i
in the global namespace, but it is used during lookup. The using-declaration uses qualified lookup to find i
; qualified lookup in the presence of using-directives is specified in [3.4.3.2 p1, p2] (quotes from N4527, the current working draft):
If the nested-name-specifier of a qualified-id nominates a namespace
(including the case where the nested-name-specifier is ::
, i.e.,
nominating the global namespace), the name specified after the
nested-name-specifier is looked up in the scope of the namespace. [...]
For a namespace X
and name m
, the namespace-qualified lookup set
S(X,m) is defined as follows: Let S'(X,m) be the set of all
declarations of m
in X
and the inline namespace set of X
(7.3.1). If
S'(X,m) is not empty, S(X,m) is S'(X,m); otherwise, S(X,m) is the
union of S(Ni,m) for all namespaces Ni nominated
by using-directives in X
and its inline namespace set.
So, for qualified lookup, the first step is to look for declarations of i
made directly in the namespace indicated by the nested-name-specifier (::
in this case). There are no such declarations, so lookup then proceeds to the second step, which is to form the set of all declarations of i
found by qualified lookup in all namespaces nominated by using-directives in the global namespace. That set is comprised of N::i
, which is the result of name lookup, and is introduced as a name in global namespace by the using declaration.
I find it worth noting (although pretty obvious) that this definition of qualified lookup is recursive: using the notation in the quote, qualified lookup in each namespace Ni will first look for declarations made directly in Ni, then, if none is found, will in turn proceed to look in the namespaces nominated by using-directives in Ni, and so on.
For what it's worth, MSVC accepts the code as well.