Title
Misplaced example about declarative nested-name-specifiers and containing scopes
Status
open
Section
9.3.4.1 [dcl.meaning.general]
Submitter
Vlad Serebrennikov

Created on 2026-10-29.00:00:00 last changed 2 days ago

Messages

Date: 2026-12-03.14:30:16

Suggested resolution:

  1. Change in 7.5.5.3 [expr.prim.id.qual] paragraph 3 as follows:

    ... A declaration that uses a declarative nested-name-specifier shall be a friend declaration or inhabit a scope that contains the entity being redeclared or specialized. [ Example:
      namespace N {
        void f();
      }
      namespace M {
        void N::f() {} // error: M does not contain N
      }
    
    -- end example ]
  2. Change in 9.3.4.1 [dcl.meaning.general] bullet 3.1 as follows:

    If the id-expression in the declarator-id of the declarator is a qualified-id Q, let S be its lookup context (6.5.5 [basic.lookup.qual]); the declaration shall inhabit a namespace scope N. [ Note: N must contain the entity being redeclared or specialized (7.5.5.3 [expr.prim.id.qual]). -- end note ]
  3. Change the example in 9.3.4.1 [dcl.meaning.general] bullet 3.4 as follows:

      namespace Q {
      namespace V {
      void f();
      }
      void V::f() { /* ... */ }
       // OK
      void V::g() { /* ... */ }
       // error: g() is not yet a member of V
      namespace V {
      void g();
      }
      }
      namespace R {
      void Q::V::g() { /* ... */ }
       // error: R doesn't enclose Q
      }
    
      namespace V {
        void f1();
      }
      namespace W {
        using V::f1;
        struct S {
          friend void f2();
        };
        void f3();
        inline namespace N {
          void f3();
        }
      }
      void W::f1() {} // error: f1 is not nominable in W
      void V::f1() {} // OK
      void W::f2() {} // OK
      void W::f3() {} // error: nominable declarations of f3 have different target scopes
    
      void V::f2() {} // error: f2 is not yet a member of V
      namespace V {
        void f2();
      }
    
Date: 2026-10-29.00:00:00

(From submission #1029.)

The example attached to 9.3.4.1 [dcl.meaning.general] bullet 3.4 does not illustrate the point being made by the preceding normative wording.

History
Date User Action Args
2026-12-03 14:30:16adminsetmessages: + msg8729
2026-10-29 00:00:00admincreate