Let me try to elaborate it.
Stack Frame: When we execute any function it create stack where all local variables and instructions reside.
And Smart Pointer: smart pointer like
std::unique_ptr allows to change ownership of object inside of smart pointer.
Now my confusion is: suppose we pass a
unique_ptr from a source function to a target function, the
rvalue will be assigned to target pointer by
std::move. Now if the function exits, the stack frame will deallocated. So will
unique_ptr in target function be a dangling pointer, since
unique_ptr is pointing to same memory location that resides in source function's stack frame?
One thing I thought is, since target function lifetime will be over before source function's lifetime. So that wont cause any such side effects. But in more complex applications with multi threaded environment, how does it go? Or what do we need to take care of?