You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The lifetime of a temporary bound to the returned value in a function return statement ([stmt.return]) is not extended; the temporary is destroyed at the end of the full-expression in the return statement.
In [stmt.return], we say
the return statement initializes the returned reference or prvalue result object of the (explicit or implicit) function call by copy-initialization from the operand.
In [class.temporary] p6.11, it should mean returned reference.
The text was updated successfully, but these errors were encountered:
A function can't really return a refernence. The return type of a function can be a reference type, but that just means that the function returns a glvalue. So maybe it'd be better to change [stmt.return].
I suggested in #5415, to say, the return statement should model a declaration T v = E where T is the return type of the function and E is the expr-or-braced-init-list of the return statement, and then say v is lvalue if T is lvalue reference type, xvalue if T is rvalue reference type, and prvlaue otherwise, such an invented declaration is a part of the full-expression established by the return statement, in this logic, the lifetime of temporary object created in the declaration is consistent with that of [class.temporary] p6.11. We can say the result of the function call is the v established by the return statement that transferred the flow control.
[class.temporary] p6.11 says:
In [stmt.return], we say
In [class.temporary] p6.11, it should mean returned reference.
The text was updated successfully, but these errors were encountered: