#include #include int* foo(); int bar(); int main(){ int64_t* ptr = foo(); int x = bar(2) printf("%d\n", *ptr); } int64_t* foo(){ int64_t x = 333; x += bar(x); return &x; // ^^ // Note that gcc is smart enough to realize this results // in undefined behaviour, and will return NULL // to try and have you "fail fast". Note that gcc won't catch // all of the cases where you use a pointer to a local variable } int64_t bar(int64_t param){ return (param * 2); }