Skip to content

Commit 853dae1

Browse files
committed
New issue from Lewis Baker: "§[exec.as.awaitable] is using "Preconditions:" when it should probably be described in the constraint"
1 parent 8a33231 commit 853dae1

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

xml/issue4358.xml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4358" status="New">
5+
<title>&sect;[exec.as.awaitable] is using "Preconditions:" when it should probably be described in the constraint</title>
6+
<section>
7+
<sref ref="[exec.as.awaitable]"/>
8+
</section>
9+
<submitter>Lewis Baker</submitter>
10+
<date>27 Aug 2025</date>
11+
<priority>99</priority>
12+
13+
<discussion>
14+
<p>
15+
In <sref ref="[exec.as.awaitable]"/> bullet 7.2 it states:
16+
</p>
17+
<blockquote>
18+
<ol style="list-style-type: none">
19+
<li><p>(7.2) &mdash; Otherwise, <tt>(void(p), expr)</tt> if <tt><i>is-awaitable</i>&lt;Expr, U&gt;</tt> is `true`,
20+
where `U` is an unspecified class type that is not `Promise` and that lacks a member named `await_transform`.
21+
<p/>
22+
<i>Preconditions</i>: <tt><i>is-awaitable</i>&lt;Expr, Promise&gt;</tt> is `true` and the expression
23+
`co_await expr` in a coroutine with promise type `U` is expression-equivalent to the same expression
24+
in a coroutine with promise type `Promise`.</p></li>
25+
</ol>
26+
</blockquote>
27+
<p>
28+
The "<i>Preconditions</i>:" sentence there refers to static properties of the program and so seems like a
29+
better fit for a <i>Mandates</i>: element or for folding into the constraint.
30+
<p/>
31+
Also, in the part of the precondition above which says "&hellip; and the expression `co_await expr` in a
32+
coroutine with promise type `U` is expression-equivalent to the same expression in a coroutine with promise
33+
type `Promise`" it is unclear how this can be satisfied, as the types involved are different and therefore
34+
the expression cannot be expression-equivalent.
35+
<p/>
36+
I think perhaps what is intended here is something along the lines of the first expression having
37+
"effects equivalent to" the second expression, instead of "expression-equivalent to"?
38+
<p/>
39+
However, I think there is a more direct way to express the intent here, by instead just requiring that
40+
<tt>decltype(<i>GET-AWAITER</i>(expr))</tt> satisfies <tt><i>is-awaiter</i>&lt;Promise&gt;</tt>.
41+
This checks whether `expr` would be a valid type to return from a `Promise::await_transform()` function.
42+
</p>
43+
44+
</discussion>
45+
46+
<resolution>
47+
<p>
48+
This wording is relative to <paper num="N5014"/>.
49+
</p>
50+
51+
<ol>
52+
53+
<li><p>Modify <sref ref="[exec.as.awaitable]"/> as indicated:</p>
54+
55+
<blockquote>
56+
<p>
57+
-7- `as_awaitable` is a customization point object. For subexpressions `expr` and `p` where `p`
58+
is an lvalue, `Expr` names the type `decltype((expr))` and `Promise` names the type
59+
<tt>decay_t&lt;decltype((p))&gt;</tt>, `as_awaitable(expr, p)` is expression-equivalent to,
60+
except that the evaluations of `expr` and `p` are indeterminately sequenced:
61+
</p>
62+
<ol style="list-style-type: none">
63+
<li><p>(7.1) &mdash; `expr.as_awaitable(p)` if that expression is well-formed.
64+
<p/>
65+
<i>Mandates</i>: <tt><i>is-awaitable</i>&lt;A, Promise&gt;</tt> is `true`, where `A` is the type of
66+
the expression above.</p></li>
67+
<li><p>(7.2) &mdash; Otherwise, <tt>(void(p), expr)</tt> if <ins><tt>decltype(<i>GET-AWAITER</i>(expr))</tt>
68+
satisfies <tt><i>is-awaiter</i>&lt;Promise&gt;</tt>.</ins><del><tt><i>is-awaitable</i>&lt;Expr, U&gt;</tt> is `true`,
69+
where `U` is an unspecified class type that is not `Promise` and that lacks a member named `await_transform`.</del>
70+
<p/>
71+
<del><i>Preconditions</i>: <tt><i>is-awaitable</i>&lt;Expr, Promise&gt;</tt> is `true` and the expression
72+
`co_await expr` in a coroutine with promise type `U` is expression-equivalent to the same expression
73+
in a coroutine with promise type `Promise`.</del></p></li>
74+
<li><p>(7.3) &mdash; [&hellip;]</p></li>
75+
<li><p>(7.4) &mdash; [&hellip;]</p></li>
76+
<li><p>(7.5) &mdash; [&hellip;]</p></li>
77+
</ol>
78+
</blockquote>
79+
80+
</li>
81+
82+
</ol>
83+
</resolution>
84+
85+
</issue>

0 commit comments

Comments
 (0)