<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1873</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="1873"></A><H4>1873.
  
Protected member access from derived class friends
</H4>
<B>Section: </B>11.8.3&#160; [<A href="https://wg21.link/class.access.base">class.access.base</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Richard Smith
 &#160;&#160;&#160;

 <B>Date: </B>2014-02-18<BR>


<P>[Moved to DR at the May, 2015 meeting.]</P>



<P>According to 11.8.3 [<A href="https://wg21.link/class.access.base#5">class.access.base</A>] paragraph 5,</P>

<BLOCKQUOTE>

<P>A member <TT>m</TT> is accessible at the point <I>R</I> when named in
class <TT>N</TT> if</P>

<UL>
<LI><P>...</P></LI>

<LI><P>
<TT>m</TT> as a member of <TT>N</TT> is protected, and <I>R</I> occurs in a member or friend of
class <TT>N</TT>, or in a member or friend of a class <TT>P</TT> derived from <TT>N</TT>, where <TT>m</TT> as a
member of <TT>P</TT> is public, private, or protected, or</P></LI>

<LI><P>...</P></LI>

</UL>

</BLOCKQUOTE>

<P>The granting of access via class <TT>P</TT> is troubling.  At the
least, there should be a restriction that <TT>P</TT> be visible at
<I>R</I>.  Alternatively, this portion of the rule could be removed
altogether; this provision does not appear to be widely used in
existing code and such references can be easily converted to use
<TT>P</TT> instead of <TT>N</TT> for naming the member.</P>

<P><B>Notes from the June, 2014 meeting:</B></P>

<P>CWG noted that removing the <TT>friend</TT> provision would
introduce an undesirable asymmetry between member functions
of <TT>P</TT> and its friends. Instead, the intent is to require
<TT>P</TT> to be a complete type at <I>R</I>.</P>

<P><B>Notes from the November, 2014 meeting:</B></P>

<P>Although the asymmetry is unfortunate, the difference
between a reference in a member function and a reference in
a friend is that the member function concretely determines
which <TT>P</TT> is in view, while the friend could be
befriended by a class that is a specialization of a class
template and thus would require instantiations that would
not otherwise occur.  CWG thus decided simply to eliminate
the friend case.</P>

<P><B>Proposed resolution, November, 2014:</B></P>

<P>Change bullet 5.3 of 11.8.3 [<A href="https://wg21.link/class.access.base">class.access.base</A>] as follows:</P>

<BLOCKQUOTE>

<P>...A member <TT>m</TT> is accessible at the
point <I>R</I> when named in class <TT>N</TT> if</P>

<UL>
<LI><P>...</P></LI>

<LI><P>
<TT>m</TT> as a member of <TT>N</TT> is protected,
and <I>R</I> occurs in a member or friend of
class <TT>N</TT>, or in a member <DEL>or friend</DEL> of a
class <TT>P</TT> derived from <TT>N</TT>, where <TT>m</TT>
as a member of <TT>P</TT> is public, private, or protected,
or</P></LI>

<LI><P>there exists...</P></LI>

</UL>

</BLOCKQUOTE>

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