This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-12-19


231. Visibility of names after using-directives

Section: 6.5.3  [basic.lookup.unqual]     Status: NAD     Submitter: Jörg Barfurth     Date: 31 May 2000

The wording of 6.5.3 [basic.lookup.unqual] paragraph 2 is misleading. It says:

The declarations from the namespace nominated by a using-directive become visible in a namespace enclosing the using-directive; see 9.8.4 [namespace.udir].

According to 9.8.4 [namespace.udir] paragraph 1, that namespace is

the nearest enclosing namespace which contains both the using-directive and the nominated namespace.

That would seem to imply the following:

    namespace outer {
        namespace inner {
            int i;
        }
        void f() {
            using namespace inner;
        }
        int j = i;   // inner::i is "visible" in namespace outer
    }

Suggested resolution: Change the first sentence of 6.5.3 [basic.lookup.unqual] paragraph 2 to read:

The declarations from the namespace nominated by a using-directive become visible in the scope in which the using-directive appears after the using-directive.

Notes from the 4/02 meeting:

After a lot of discussion of possible wording changes, we decided the wording should be left alone. 6.5.3 [basic.lookup.unqual] paragraph 2 is not intended to be a full specification; that's in 9.8.4 [namespace.udir] paragraph 1. See also 6.4.6 [basic.scope.namespace] paragraph 1.