After returning someFunc() and calling another function, the space that was used for stackInt will be used for some other variable in the new function. Therefore, the function someOtherFunc() cannot safely assume that if it stores a copy of the passed pointer, that pointer will remain valid. If he starts a copy of the value that was indicated, this is normal.
So, although transferring stack variables to an address (for example, someOtherFunc() can change the value of stackInt ), and if code appeared in someFunc() in someFunc() , which turned to it after the call, the value cannot be 4 more), it is not safe to store a pointer and expect it to point anywhere when after returning someFunc() .
source share