Each time a function is called, a new copy of its arguments and local (automatic) variables is created. The store is reused after the function returns, so a pointer to a local variable should never be returned. The contents of the location pointer to will change unpredictably:
Code:
int* fp() { int local = 1; /* ... */ return &local; } // bad
This error is less common than the equivalent error using references:
Code:
int& fr() { int local = 1; /* ... */ return local; } // bad
Fortunately, a compiler can easily warn about returning references to local variables.