|Synopsis:||A function must never return, or in any other way give access to, references or pointers to local variables outside the scope in which they are declared|
|Category:||Object Life Cycle|
If a function returns a reference or a pointer to a local variable, the memory to which it refers will already have been deallocated, when this reference or pointer is used. Note that the scope in this rule refers to the lifetime-scope. It is never allowed that a function gives access to a local automatic stack variable. However, if the lifetime of a local variable exceeds the lifetime of its block, then it may well be appropriate to give access to it from other scopes. This might be the case for static or new allocated objects.