Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the life-time of a function parameter (citation needed)? [closed]

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').

like image 854
AnArrayOfFunctions Avatar asked Dec 04 '25 12:12

AnArrayOfFunctions


1 Answers

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.