Ignoring programming style and design, is it \"safe\" to call delete on a variable allocated on the stack?
For example:
int nAmount;
delete &am
You already answered the question yourself. delete
must only be used for pointers optained through new
. Doing anything else is plain and simple undefined behaviour.
Therefore there is really no saying what happens, anything from the code working fine through crashing to erasing your harddrive is a valid outcome of doing this. So please never do this.