Open xmh0511 opened 2 years ago
Maybe, we could change [stmt.return] p5 to clarify this issue, that is:
The value computation or the copy-initialization of the returned reference of the call is considered part of the full-expression established by the operand of the return statement, which is sequenced before the destruction of temporaries at the end of the full-expression, which, in turn, is sequenced before the destruction of local variables ([stmt.jump]) of the block enclosing the return statement.
If we consider any evaluation of a prvalue(i.e. initialize result object or compute the value for operation) is a kind of value computation, see https://github.com/cplusplus/draft/issues/5477
The current wording does not seem to specify the value computation of the function call expression
fun()
and the evaluation of expressions within the function body(e.g. the side effect of expressiona
). Every evaluation of the expressions before return statement ought to be guaranteed to be sequenced before the value computation of the function call. There is no explicit wording for this point. The relevant wording about the sequence for function call are defined in [expr.call] and [basic.exec] [expr.call] p8[intro.execution] p11
Neither of them can clarify the above issue.