Description
Full name of submitter (unless configured in github; will be published with the issue): Jim X
The issues in cplusplus/draft#4723, cplusplus/draft#4847, cplusplus/draft#4107, cplusplus/draft#4847, #159, and cplusplus/draft#6001 (maybe omit some other issues) can all be subsumed to the issue that:
the result of the function call is not clear, and certain rules defined in [stmt.return] conflict with that of [expr.call]
Suggested resolution
We can just say
The return statement with operand models a declaration
T v = E;
whereT
is the return type of the function andE
is(expr-or-braced-init-list)
if the expr-or-braced-init-list of the return statement is an expression and is expr-or-braced-init-list otherwise,v
is anlvalue
ifT
is an lvalue reference type or an rvalue reference to function type , anxvalue
ifT
is an rvalue reference to object type, and a prvalue otherwise. The result of the function call is thev
established by the return statement that transferred the flow control.The copy-initialization of the result object of the call is sequenced before the destruction of local variables ([stmt.jump]) of the block enclosing the return statement.
This definition keeps the consistent meaning with the initialization that occurs in a return statement, and the lifetime of temporary objects created in the return statement, in the current draft.