int * ref () {
int tmp = 100;
return &tmp;
}
int main () {
int * a = ref();
cout << *a << endl;
}
I know the function ref () is allocated stack space. It will get destroyed as soon as the function exits. So the complier will give warning information. But my question is why the returning result is still correct.