Title
Block-scope extern declarations in namespace members
Status
cd1
Section
6.6 [basic.link]
Submitter
Daveed Vandevoorde

Created on 2004-07-23.00:00:00 last changed 188 months ago

Messages

Date: 2005-10-15.00:00:00

[Voted into WP at October 2005 meeting.]

Date: 2004-10-15.00:00:00

Proposed resolution (October 2004):

Add the following text as a new paragraph at the end of 9.8.2 [namespace.def]:

The enclosing namespaces of a declaration are those namespaces in which the declaration lexically appears, except for a redeclaration of a namespace member outside its original namespace (e.g., a definition as specified in _N4868_.9.8.2.3 [namespace.memdef]). Such a redeclaration has the same enclosing namespaces as the original declaration. [Example:
  namespace Q {
    namespace V {
      void f(); // enclosing namespaces are the global namespace, Q, and Q::V
      class C { void m(); };
    }
    void V::f() { // enclosing namespaces are the global namespace, Q, and Q::V
      extern void h(); // ... so this declares Q::V::h
    }
    void V::C::m() { // enclosing namespaces are the global namespace, Q, and Q::V
    }
  }

end example]

Date: 2004-07-23.00:00:00

Consider the following bit of code:

    namespace N {
      struct S {
        void f();
      };
    }
    using namespace N;
    void S::f() {
      extern void g();  // ::g or N::g?
    }

In 6.6 [basic.link] paragraph 7 the Standard says (among other things),

When a block scope declaration of an entity with linkage is not found to refer to some other declaration, then that entity is a member of the innermost enclosing namespace.

The question then is whether N is an “enclosing namespace” for the local declaration of g()?

History
Date User Action Args
2008-10-05 00:00:00adminsetstatus: wp -> cd1
2006-04-22 00:00:00adminsetstatus: dr -> wp
2005-10-22 00:00:00adminsetmessages: + msg1271
2005-10-22 00:00:00adminsetstatus: ready -> dr
2005-05-01 00:00:00adminsetstatus: review -> ready
2004-11-07 00:00:00adminsetmessages: + msg1050
2004-11-07 00:00:00adminsetstatus: open -> review
2004-07-23 00:00:00admincreate