Returning pointers and references to local objects or variables has undefined behavior because the data goes out of scope when the function returns. In other words, don't do it.
If behavior of returning address of local variable of a function is undefined then what is the use of a function returning pointer... like if a pointer is made global and used inside a function , or is passed to a function as one of its arguments and the function is doing manipulation at that address then it doesn't need to return that address.