Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[editoral] the ambiguity in [stmt.return] p4 #5215

Closed
xmh0511 opened this issue Jan 19, 2022 · 5 comments · Fixed by #5217
Closed

[editoral] the ambiguity in [stmt.return] p4 #5215

xmh0511 opened this issue Jan 19, 2022 · 5 comments · Fixed by #5217
Assignees

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented Jan 19, 2022

[stmt.return] p4 says:

Otherwise, flowing off the end of a function other than main or a coroutine results in undefined behavior.

It seems the sentence can be read as two meanings, which are:

  • flowing off the end of a function other than (main or a coroutine) results in undefined behavior.
  • flowing off the end of a function other than main or flowing off the end of a coroutine results in undefined behavior.

we can infer that the second one is a wrong interpretation but this is based on that we get the clue after reading [dcl.fct.def.coroutine] p11.

@jwakely
Copy link
Member

jwakely commented Jan 19, 2022

They mean the same thing. A coroutine is a function, so it doesn't matter if you group "a coroutine" with "a function" or not.

@xmh0511
Copy link
Contributor Author

xmh0511 commented Jan 19, 2022

@jwakely So, you suppose that, if the sentence is parsed as the second one it would be a duplicate expound about the function, thus, only the first one is a reasonable way to parse the sentence?

@jwakely
Copy link
Member

jwakely commented Jan 19, 2022

I think it doesn't matter which way you parse it, it means the same thing.

@xmh0511
Copy link
Contributor Author

xmh0511 commented Jan 20, 2022

I think it doesn't matter which way you parse it, it means the same thing.

Uh, Do you think

flowing off the end of a function that is neither main nor a coroutine results in UB

has the same meaning with

flowing off the end of a function that is not main, or flowing off the end of a coroutine, results in UB

? The latter obviously conflicts with [dcl.fct.def.coroutine] p11

The coroutine state is destroyed when control flows off the end of the coroutine

@jwakely
Copy link
Member

jwakely commented Jan 20, 2022

Doh, I implicitly negated the coroutine part, sorry. I need to learn to read.

I think your rephrasing as "a function that is neither main nor a coroutine" would be an improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants