Is the life-time of a function parameter equal of an unnamed temporary passed as an 'rvalue' reference (which is equal of the expression called the function)? My 'gcc' compiler shows that it is. But I want to see an actual standard document that states it too (possible the newest 'C++11' or 'C++14').
Although the standard does definitely claim that the lifetime of a parameter ends when the function in which it is defined returns, as answered by Anton Savin, this is not what implementations do, and the standard will likely be changed to allow what implementations do:
WG decided to make it unspecified whether parameter objects are destroyed immediately following the call or at the end of the full-expression to which the call belongs.
This means the lifetime of a function parameter would become unspecified. It might end as soon as the function returns, or it might end later.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With