<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1309</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="1309"></A><H4>1309.
  
Incorrect note regarding lookup of a member of the current instantiation
</H4>
<B>Section: </B>13.8.3.2&#160; [<A href="https://wg21.link/temp.dep.type">temp.dep.type</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Johannes Schaub
 &#160;&#160;&#160;

 <B>Date: </B>2011-05-05<BR>


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



<P>The note in 13.8.3.2 [<A href="https://wg21.link/temp.dep.type#7">temp.dep.type</A>] paragraph 7 reads,</P>

<BLOCKQUOTE>

[<I>Note:</I> the result of name lookup differs only when the member
of the current instantiation was found in a non-dependent base class
of the current instantiation and a member with the same name is also
introduced by the substitution for a dependent base class of the
current instantiation.  &#8212;<I>end note</I>]

</BLOCKQUOTE>

<P>However, this is not correct.  Consider the following example:</P>

<PRE>
  struct Y { int X; };

  template&lt;typename T&gt;
  struct A : Y {
   enum B : int;
   void f() { A::X; } //<SPAN CLASS="cmnt"> finds </SPAN>Y::X<SPAN CLASS="cmnt"> here!</SPAN>
  };

  template&lt;typename T&gt;
  enum A&lt;T&gt;::B : int {
   X //<SPAN CLASS="cmnt"> introduces member </SPAN>A::X<SPAN CLASS="cmnt"> into </SPAN>A&lt;T&gt;<SPAN CLASS="cmnt">!</SPAN>
  };

  void g() { A&lt;int&gt; a; a.f(); }
</PRE>

<P>
<TT>A::X</TT> is a member of the current instantiation, so
paragraph 7 requires it to be looked up again when instantiating and
to give a diagnostic if the lookup differs from the lookup in the
definition context. The note incorrectly indicates that this can only
happen if the conflicting name was introduced by a dependent base
class.</P>

<P><B>Proposed resolution (August, 2011) [SUPERSEDED]:</B></P>

<P>Change 13.8.3.2 [<A href="https://wg21.link/temp.dep.type#7">temp.dep.type</A>] paragraph 7 as follows:</P>

<BLOCKQUOTE>

<P>...If the result of this lookup differs from the result of name
lookup in the template definition context, name lookup is
ambiguous. <DEL>[<I>Note:</I> the result of name lookup differs only
when the member of the current instantiation was found in a
non-dependent base class of the current instantiation and a member
with the same name is also introduced by the substitution for a
dependent base class of the current instantiation. &#8212;<I>end
note</I>]</DEL> <INS>[<I>Example:</I></INS>
</P>

<PRE>
<INS>  struct A {
    int m;
  };

  struct B {
    int m;
  };

  template&lt;typename T&gt;
  struct C : A, T {
    int f() { return this-&gt;m; } //<SPAN CLASS="cmnt"> finds </SPAN>A::m<SPAN CLASS="cmnt"> in the template definition context</SPAN>
  };

  int g(C&lt;B&gt; cb) {
    return cb.f();              //<SPAN CLASS="cmnt"> error: finds both </SPAN>A::m<SPAN CLASS="cmnt"> and </SPAN>B::m<SPAN CLASS="cmnt"> in the template instantiation context</SPAN>
  }</INS>
</PRE>

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

</BLOCKQUOTE>

<P><B>Notes from the December, 2011 teleconference:</B></P>

<P>Changes to the exposition were suggested and the issue returned to
"drafting" status.</P>

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

<P>Change 13.8.3.2 [<A href="https://wg21.link/temp.dep.type#7">temp.dep.type</A>] paragraph 7 as follows:

<BLOCKQUOTE>

<P>...If the result of this lookup differs from the result
of name lookup in the template definition context, name
lookup is ambiguous.  <DEL>[<I>Note:</I> the result of name
lookup differs only when the member of the current
instantiation was found in a non-dependent base class of the
current instantiation and a member with the same name is
also introduced by the substitution for a dependent base
class of the current instantiation. &#8212;<I>end
note</I>]</DEL> <INS>[<I>Example:</I></INS>
</P>

<PRE>
<INS>  struct A {
    int m;
  };

  struct B {
    int m;
  };

  template&lt;typename T&gt;
  struct C : A, T {
    int f() { return this-&gt;m; }  //<SPAN CLASS="cmnt"> finds </SPAN>A::m<SPAN CLASS="cmnt"> in the template definition context</SPAN>
  };

  template int C&lt;B&gt;::f();        //<SPAN CLASS="cmnt"> error: finds both </SPAN>A::m<SPAN CLASS="cmnt"> and </SPAN>B::m</INS>
</PRE>

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

</BLOCKQUOTE>
</P>

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