<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1119</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="1119"></A><H4>1119.
  
Missing case in description of member access ambiguity
</H4>
<B>Section: </B>7.6.1.5&#160; [<A href="https://wg21.link/expr.ref">expr.ref</A>]
 &#160;&#160;&#160;

 <B>Status: </B>C++11
 &#160;&#160;&#160;

 <B>Submitter: </B>US
 &#160;&#160;&#160;

 <B>Date: </B>2010-08-02<BR><BR>


<P>[Voted into the WP at the November, 2010 meeting.]</P>

<A href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3296.html#US32">N3092 comment
  US&#160;32<BR></A>

<P>According to 7.6.1.5 [<A href="https://wg21.link/expr.ref#5">expr.ref</A>] paragraph 5,</P>

<BLOCKQUOTE>

If <TT>E2</TT> is a non-static data member or a non-static
member function, the program is ill-formed if the class of
which <TT>E2</TT> is directly a member is an ambiguous base
(6.5.2 [<A href="https://wg21.link/class.member.lookup">class.member.lookup</A>]) of the naming class
(11.8.3 [<A href="https://wg21.link/class.access.base">class.access.base</A>]) of <TT>E2</TT>.

</BLOCKQUOTE>

<P>This does not cover the following case:</P>

<PRE>
    struct A { int i; };
    struct B: A { };
    struct C: A, B { };
    void f(C* p) {
      p-&gt;A::i; // Should be ambiguous
    }
</PRE>

<P><B>Notes (August, 2010):</B></P>

<P>The example in the FCD National Body comment is incorrect: it is
missing the <TT>A::</TT> in the next-to-last line.</P>

<P>The ambiguity actually is covered in the Standard but in an
unexpected location: 11.8.3 [<A href="https://wg21.link/class.access.base#6">class.access.base</A>] paragraph 6:</P>

<BLOCKQUOTE>

If a class member access operator, including an implicit
&#8220;<TT>this-&gt;</TT>,&#8221; is used to access a
non-static data member or non-static member function, the
reference is ill-formed if the left operand (considered as a
pointer in the &#8220;<TT>.</TT>&#8221; operator case)
cannot be implicitly converted to a pointer to the naming
class of the right operand.

</BLOCKQUOTE>

<P>An explanatory note, including a cross-reference to
11.8.3 [<A href="https://wg21.link/class.access.base">class.access.base</A>], should be added to
7.6.1.5 [<A href="https://wg21.link/expr.ref#6">expr.ref</A>] paragraph 6.</P>

<P><B>Proposed resolution (September, 2010):</B></P>

<P>Change 7.6.1.5 [<A href="https://wg21.link/expr.ref#5">expr.ref</A>] paragraph 5 as follows:</P>

<BLOCKQUOTE>

If <TT>E2</TT> is a non-static data member or a non-static member
function, the program is ill-formed if the class of which <TT>E2</TT>
is directly a member is an ambiguous base (6.5.2 [<A href="https://wg21.link/class.member.lookup">class.member.lookup</A>])
of the naming class (11.8.3 [<A href="https://wg21.link/class.access.base">class.access.base</A>]) of
<TT>E2</TT>. <INS>[<I>Note:</I> The program is also ill-formed if the
naming class is an ambiguous base of the class type of the object
expression; see 11.8.3 [<A href="https://wg21.link/class.access.base">class.access.base</A>]. &#8212;<I>end
note</I>]</INS>

</BLOCKQUOTE>

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