the concept of deletion doesn't work. Usually when the function returns, the stack pointer is moved to its original position when entering the function. For example
void solve(int x) {
int y = x+x;
}
int main() {
solve(5);
}
will be translated into (assuming an unoptimizing compiler)
solve:
push ebp
mov ebp, esp
sub esp, 8
mov eax, [ebp+8]
mov [ebp-4], eax
mov eax, [ebp-4]
add eax, eax
mov [ebp-8], eax
add esp, 8
leave
ret
main:
push ebp
mov ebp, esp
push 5
call solve
add esp, 4
leave
ret
So, when solve is executed, the stack looks like
+---------+ <-- main's frame
| ebp |
+---------+ <-- ebp points here
| 5 |
+---------+
| ret0 | <-- address of 'add esp, 4' in main
+---------+ <-- solve's frame
| ebp | <-- saved ebp
+---------+ <-- ebp now points here
| 5 | ; argument copied into [ebp-4]
+---------+
| 10 | ; [ebp-8]
+---------+ <-- esp points here before returning from solve
After the control returns to main at add esp, 4 instruction, the stack looks like this
+---------+ <-- main's frame
| ebp |
+---------+ <-- ebp points here
| 5 |
+---------+ <-- esp points here
| ret0 |
+---------+
| ebp |
+---------+
| 5 |
+---------+
| 10 |
+---------+
So, we can see that the value is not really 'deleted'. It may be overwritten if any function call uses those stack locations