cplusplus / cplusplus/draft

[stmt.return.coroutine] p3 the original function-body vs. the replaced function-body

Open
#5,214 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

[stmt.return.coroutine] p3 states:

If p.return_­void() is a valid expression, flowing off the end of a coroutine's function-body is equivalent to a co_­return with no operand; otherwise flowing off the end of a coroutine's function-body results in undefined behavior.

which the bolded function-bodys refer to? Since [dcl.fct.def.coroutine] p5 states that

A coroutine behaves as if its function-body were replaced by...

If we argue that the replace function-body is just notional(i.e., the replacement process is not actually happened), I would say the expound in [dcl.fct.def.coroutine] p11 is anyway based on the replaced one.

The coroutine state is destroyed when control flows off the end of the coroutine or the destroy member function ([coroutine.handle.resumption]) of a coroutine handle ([coroutine.handle]) that refers to the coroutine is invoked.

Presumably, the end of the coroutine refers to the portion after co_await promise.final_suspend() ; in the replaced one. Maybe, there is room for improvement for the above provision in order to eliminate the ambiguity.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read [stmt.return.coroutine] p3 alongside [dcl.fct.def.coroutine] p5 and p11, focusing on whether “function-body” refers to the original or the notional replacement. Compare the wording around control flowing off the end and determine what clarification is needed to remove the ambiguity.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.