I wrote such a function when I read the book: #include
INT & FN (INT i)
{
INT a = i;
Return A;
}
void main ()
{
INT B = 2, C;
C = fn (b);
}
Compiled passed the warned, thinking about it or is related to the scope.
For the above functions, for the returned function fn (), the value of A is not assigned to a temporary variable, only the address of the address is passed to the call function, and the call function is used to find a value of a And assign this value to C. However, the scope of the A in the fn () ends at the end of the function, and should be the address of a variable that has not yet ended under normal circumstances. Therefore, the compiler will give a warning.
But I still don't understand, what kind of processing is given by the variable compiler ending in the scope, is the complete destruction of the recovery space, or the end of the procedure is completed, or other processing methods. Also ask Heroes to advise.