Consider the following code.
#include
int *abc(); // this function returns a pointer of type int
int main()
{
int *ptr;
ptr = abc();
Well, undefined behavior is, undefined. You can never rely on UB (or on an output of a program invoking UB).
Maybe, just maybe in your environment and for your code, the memory location allocated for the local variable is not reclaimed by the OS and still accessible, but there's no guarantee that it will have the same behavior for any other platform.