<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 705</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="705"></A><H4>705.
  
Suppressing argument-dependent lookup via parentheses
</H4>
<B>Section: </B>6.5.4&#160; [<A href="https://wg21.link/basic.lookup.argdep">basic.lookup.argdep</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>29 July, 2008<BR>


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



<P>During the discussion of <A HREF="704.html">issue 704</A>,
some people expressed a desire to reconsider whether parentheses
around the name of the function in a function call should suppress
argument-dependent lookup, on the basis that this is overly subtle
and not obvious.  Others pointed out that this technique is used
(both intentionally and inadvertently) in existing code and changing
the behavior could cause problems.</P>

<P>It was also observed that the normative text that specifies this
behavior is itself subtle, relying an a very precise interpretation
of the preposition used in 6.5.4 [<A href="https://wg21.link/basic.lookup.argdep#1">basic.lookup.argdep</A>] paragraph 1:</P>

<BLOCKQUOTE>

When an unqualified name is used as the <I>postfix-expression</I>
in a function call...

</BLOCKQUOTE>

<P>This is taken to mean that something like <TT>(f)(x)</TT>
is not subject to argument-dependent lookup because the name
<TT>f</TT> is used <I>in</I> but not <I>as</I> the
<I>postfix-expression</I>.  This could be confusing, especially
in light of the use of the term <I>postfix-expression</I> to
refer to the name inside the parentheses, not to the
parenthesized expression, in 12.2.2.2 [<A href="https://wg21.link/over.match.call#1">over.match.call</A>] paragraph 1.
  If the decision is to preserve this effect of
a parenthesized name in a function call, the wording should
probably be revised to specify it more explicitly.</P>

<P><B>Notes from the September, 2008 meeting:</B></P>

<P>The CWG agreed that the suppression of argument-dependent
lookup by parentheses surrounding the <I>postfix-expression</I>
is widely known and used in the C++ community and must be
preserved.  The wording should be changed to make this
effect clearer.</P>

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

<P>Change 6.5.4 [<A href="https://wg21.link/basic.lookup.argdep#1">basic.lookup.argdep</A>] paragraph 1 as follows:</P>

<BLOCKQUOTE>

When <DEL>an unqualified name is used as</DEL> the
<I>postfix-expression</I> in a function call (7.6.1.3 [<A href="https://wg21.link/expr.call">expr.call</A>]) <INS>is an <I>unqualified-id</I></INS>, other
namespaces not considered during the usual unqualified lookup
(6.5.3 [<A href="https://wg21.link/basic.lookup.unqual">basic.lookup.unqual</A>]) may be searched...

</BLOCKQUOTE>

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

<P>Change 6.5.4 [<A href="https://wg21.link/basic.lookup.argdep#1">basic.lookup.argdep</A>] paragraph 1 as follows:</P>

<BLOCKQUOTE>

<P>When <DEL>an unqualified name is used as</DEL> the
<I>postfix-expression</I> in a function call (7.6.1.3 [<A href="https://wg21.link/expr.call">expr.call</A>]) <INS>is an <I>unqualified-id</I></INS>, other
namespaces not considered during the usual unqualified lookup
(6.5.3 [<A href="https://wg21.link/basic.lookup.unqual">basic.lookup.unqual</A>]) may be searched, and in those namespaces,
namespace- scope friend function declarations (11.8.4 [<A href="https://wg21.link/class.friend">class.friend</A>]) not otherwise visible may be found.  These modifications
to the search depend on the types of the arguments (and for template
template arguments, the namespace of the template argument).
<INS>[<I>Example:</I></INS>
</P>

<PRE>
<INS>    namespace N {
      struct S { };
      void f(S);
    }

    void g() {
      N::S s;
      f(s);      //<SPAN CLASS="cmnt"> calls </SPAN>N::f
      (f)(s);    //<SPAN CLASS="cmnt"> error: </SPAN>N::f<SPAN CLASS="cmnt"> not considered; parentheses prevent argument-dependent lookup</SPAN>
    }
</INS>
</PRE>

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

</BLOCKQUOTE>

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