<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2465</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="2465"></A><H4>2465.
  
Coroutine parameters passed to a promise constructor
</H4>
<B>Section: </B>9.6.4&#160; [<A href="https://wg21.link/dcl.fct.def.coroutine">dcl.fct.def.coroutine</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Gor Nishanov
 &#160;&#160;&#160;

 <B>Date: </B>2020-10-19<BR>


<P>[Accepted as a DR at the June, 2021 meeting.]</P>

<P>The resolution of <A HREF="2436.html">issue 2436</A>
(in <A HREF="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2107r0.html">P2107R0</A>)
deleted the sentence</P>

<BLOCKQUOTE>

A reference to a parameter in the <I>function-body</I> of
the coroutine and in the call to the coroutine promise
constructor is replaced by a reference to its copy.

</BLOCKQUOTE>

<P>replacing it with new wording in 7.5.5.2 [<A href="https://wg21.link/expr.prim.id.unqual#1">expr.prim.id.unqual</A>] paragraph 1:
</P>

<BLOCKQUOTE>

An <I>identifier</I> that names a coroutine parameter refers
to the copy of the parameter (9.6.4 [<A href="https://wg21.link/dcl.fct.def.coroutine">dcl.fct.def.coroutine</A>]).

</BLOCKQUOTE>

<P>This new approach no longer covers coroutine parameters
passed to a promise constructor, since the constructor call
is implicit, as described in 7.5.5.2 [<A href="https://wg21.link/expr.prim.id.unqual#5">expr.prim.id.unqual</A>] paragraph 5.
</P>

<P><U>Suggested resolution:</U></P>

<OL>
<LI><P>Change 7.5.5.2 [<A href="https://wg21.link/expr.prim.id.unqual#4">expr.prim.id.unqual</A>] paragraph 4 as follows:</P></LI>

<BLOCKQUOTE>

In the following, <TT>p</TT><SUB><I>i</I></SUB> is an lvalue
of type <TT>P</TT><SUB><I>i</I></SUB>,
where <TT>p</TT><SUB>1</SUB> denotes <TT>*this</TT>
and <TT>p</TT><SUB><I>i</I>+1</SUB> denotes
the <I>i</I><SUP>th</SUP> function parameter for a
non-static member function,
and <TT>p</TT><SUB><I>i</I></SUB> denotes
the <I>i</I><SUP>th</SUP> function parameter otherwise.
<INS>Let <TT>q</TT><SUB><I>i</I></SUB> be the corresponding
parameter copy, as described below.</INS>

</BLOCKQUOTE>

<LI><P>Change 7.5.5.2 [<A href="https://wg21.link/expr.prim.id.unqual#5.7">expr.prim.id.unqual</A>] bullet 5.7 as follows:</P></LI>

<BLOCKQUOTE>

<P>A coroutine behaves as if its <I>function-body</I> were
replaced by...</P>

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

<LI><P>
<I>promise-constructor-arguments</I> is determined as
follows: overload resolution is performed on a promise
constructor call created by assembling an argument list with
lvalues <TT><DEL>p</DEL><INS>q</INS></TT><SUB>1</SUB>
... <TT><DEL>p</DEL><INS>q</INS></TT><SUB><I>n</I></SUB>.
If a viable constructor is found
(12.2.3 [<A href="https://wg21.link/over.match.viable">over.match.viable</A>]),
then <I>promise-constructor-arguments</I>
is <TT>(<DEL>p</DEL><INS>q</INS></TT><SUB>1</SUB><TT>, ... ,
<DEL>p</DEL><INS>q</INS></TT><SUB><I>n</I></SUB><TT>)</TT>,
otherwise <I>promise-constructor-arguments</I> is
empty.</P></LI>

</UL>

</BLOCKQUOTE>

</OL>

<P><B>Proposed resolution (April, 2021):</B></P>

<OL>
<LI><P>Change 9.6.4 [<A href="https://wg21.link/dcl.fct.def.coroutine#4">dcl.fct.def.coroutine</A>] paragraph 4 as follows:</P></LI>

<BLOCKQUOTE>

In the following, <TT>p</TT><SUB><I>i</I></SUB> is an lvalue
of type <TT>P</TT><SUB><I>i</I></SUB>,
where <TT>p</TT><SUB>1</SUB> denotes <TT>*this</TT>
and <TT>p</TT><SUB><I>i</I>+1</SUB> denotes
the <I>i</I><SUP>th</SUP> function parameter for a
non-static member function,
and <TT>p</TT><SUB><I>i</I></SUB> denotes
the <I>i</I><SUP>th</SUP> function parameter otherwise.
<INS>For a non-static member function,
<TT>q</TT><SUB>1</SUB> is an lvalue that denotes
<TT>*this</TT>; any other <TT>q</TT><SUB><I>i</I></SUB>
is an lvalue that denotes the parameter copy corresponding
to <TT>p</TT><SUB><I>i</I></SUB>, as described below.</INS>

</BLOCKQUOTE>

<LI><P>Change 9.6.4 [<A href="https://wg21.link/dcl.fct.def.coroutine#5.7">dcl.fct.def.coroutine</A>] bullet 5.7 as follows:</P></LI>

<BLOCKQUOTE>

<P>A coroutine behaves as if its <I>function-body</I> were
replaced by: ... where</P>

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

<LI><P>
<I>promise-constructor-arguments</I> is determined as
follows: overload resolution is performed on a promise
constructor call created by assembling an argument list <DEL>with
lvalues <TT>p</TT><SUB>1</SUB>&#160;...&#160;<TT>p</TT><SUB><I>n</I></SUB></DEL>
<INS><TT>q</TT><SUB>1</SUB>&#160;...&#160;<TT>q</TT><SUB><I>n</I></SUB></INS>.
If a viable constructor is found
(12.2.3 [<A href="https://wg21.link/over.match.viable">over.match.viable</A>]),
then <I>promise-constructor-arguments</I> is <DEL><TT>(p1, ... ,
p</TT><SUB><I>n</I></SUB><TT>)</TT></DEL>
<INS><TT>(q</TT><SUB>1</SUB><TT>, ... ,
q</TT><SUB><I>n</I></SUB><TT>)</TT></INS>,
otherwise <I>promise-constructor-arguments</I> is
empty.</P></LI>

</UL>

</BLOCKQUOTE>

</OL>

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