<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 474</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="474"></A><H4>474.
  
Block-scope <TT>extern</TT> declarations in namespace members
</H4>
<B>Section: </B>6.7&#160; [<A href="https://wg21.link/basic.link">basic.link</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD1
 &#160;&#160;&#160;

 <B>Submitter: </B>Daveed Vandevoorde
 &#160;&#160;&#160;

 <B>Date: </B>23 Jul 2004<BR>


<P>[Voted into WP at October 2005 meeting.]</P>



<P>Consider the following bit of code:</P>

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

<P>In 6.7 [<A href="https://wg21.link/basic.link#7">basic.link</A>] paragraph 7 the Standard says
(among other things),</P>

<BLOCKQUOTE>
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.
</BLOCKQUOTE>

<P>The question then is whether <TT>N</TT> is an &#8220;enclosing
namespace&#8221; for the local declaration of <TT>g()</TT>?</P>

<P><B>Proposed resolution (October 2004):</B></P>

<P>Add the following text as a new paragraph at the end of
9.9.2 [<A href="https://wg21.link/namespace.def">namespace.def</A>]:</P>

<BLOCKQUOTE>
The <I>enclosing namespaces</I> 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 [<A href="https://wg21.link/namespace.memdef">namespace.memdef</A>]). Such a redeclaration has the same enclosing
namespaces as the original declaration. [<I>Example:</I>

<PRE>
  namespace Q {
    namespace V {
      void f(); //<SPAN CLASS="cmnt"> enclosing namespaces are the global namespace, </SPAN>Q<SPAN CLASS="cmnt">, and </SPAN>Q::V
      class C { void m(); };
    }
    void V::f() { //<SPAN CLASS="cmnt"> enclosing namespaces are the global namespace, </SPAN>Q<SPAN CLASS="cmnt">, and </SPAN>Q::V
      extern void h(); //<SPAN CLASS="cmnt"> ... so this declares </SPAN>Q::V::h
    }
    void V::C::m() { //<SPAN CLASS="cmnt"> enclosing namespaces are the global namespace, </SPAN>Q<SPAN CLASS="cmnt">, and </SPAN>Q::V
    }
  }
</PRE>

<P>&#8212;<I>end example</I>]</P>
</BLOCKQUOTE>

<BR><BR>
</BODY>
</HTML>
