<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2331</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="2331"></A><H4>2331.
  
Redundancy in description of class scope
</H4>
<B>Section: </B>6.4.7&#160; [<A href="https://wg21.link/basic.scope.class">basic.scope.class</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Thomas K&#246;ppe
 &#160;&#160;&#160;

 <B>Date: </B>2016-12-07<BR>


<P>[Accepted at the November, 2020 meeting as part of paper P1787R6 and
moved to DR at the February, 2021 meeting.]</P>

<P>[Accepted as a DR at the February, 2019 meeting.]</P>

<P>The first four paragraphs of 6.4.7 [<A href="https://wg21.link/basic.scope.class">basic.scope.class</A>] are
somewhat redundant. In particular:</P>

<UL>
<LI><P>The normative paragraphs are 4 and 2.</P></LI>

<LI><P>Paragraph 1 is subsumed by paragraph 4.</P></LI>

<LI><P>Paragraph 3 follows from existing rules for name hiding.</P></LI>

</UL>

<P>This
is <A HREF="https://github.com/cplusplus/draft/issues/1169">editorial
issue 1169</A>.
</P>

<P><B>Proposed resolution (November, 2018):</B></P>

<P>In 6.4.7 [<A href="https://wg21.link/basic.scope.class">basic.scope.class</A>], delete paragraph 1, move paragraph 4 to
the beginning, and make paragraph 3 a note:</P>

<BLOCKQUOTE>

<P>
<DEL>The potential scope of a name declared in a class consists
not only of the declarative region following the name's
point of declaration, but also of all complete-class
contexts (11.4 [<A href="https://wg21.link/class.mem">class.mem</A>]) of that class.</DEL>
</P>

<P><INS>The potential scope of a declaration that extends to or past
the end of a class definition also extends to the regions
defined by its member definitions, even if the members are
defined lexically outside the class (this
includes static data member definitions, nested class
definitions, and member function definitions, including the
member function body and any portion of the declarator part
of such definitions which follows the <I>declarator-id</I>,
including a <I>parameter-declaration-clause</I> and any
default arguments (9.3.4.7 [<A href="https://wg21.link/dcl.fct.default">dcl.fct.default</A>])).</INS></P>

<P>A name <TT>N</TT> used in a class <TT>S</TT> shall refer
to the same declaration in its context and when re-evaluated
in the completed scope of <TT>S</TT>. No diagnostic is
required for a violation of this rule.</P>

<P>
<INS>[<I>Note:</I></INS>
A name declared within a member function hides a declaration
of the same name whose scope extends to or past the end of
the member function's class <INS>(_N4868_.6.4.10 [<A href="https://wg21.link/basic.scope.hiding">basic.scope.hiding</A>])</INS>.
<INS>&#8212;<I>end note</I>]</INS>
</P>

<P><DEL>The potential scope of a declaration that extends to or past
the end of a class definition also extends to the regions
defined by its member definitions, even if the members are
defined lexically outside the class (this
includes static data member definitions, nested class
definitions, and member function definitions, including the
member function body and any portion of the declarator part
of such definitions which follows the <I>declarator-id</I>,
including a <I>parameter-declaration-clause</I> and any
default arguments (9.3.4.7 [<A href="https://wg21.link/dcl.fct.default">dcl.fct.default</A>])).</DEL></P>

</BLOCKQUOTE>

<P><B>Additional note, March, 2019:</B></P>

<P>The resolution emoves the rule that a class member name
can be found by unqualified lookup prior to its point of
definition in complete-class contexts, at least in
non-defining member declarations:</P>

<PRE>
  struct X {
    void f(int n = k); //<SPAN CLASS="cmnt"> was valid, now ill-formed</SPAN>
    static int k;
  };
</PRE>

<P>Relatedly, the "member definitions" rule (formerly p4, now
p2) that was used to justify the removal of p1 is wrong
(both before and after that change):</P>

<PRE>
  struct A {
    void f(B b) {} //<SPAN CLASS="cmnt"> was always (incorrectly) valid</SPAN>
    struct B {};
  };
</PRE>

<P>For these reasons, this issue has been returned to "drafting"
status.</P>

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