3

Possible Duplicate:
C++ calling delete on variable allocated on the stack

int i = 10;
int* iP = &i;
delete iP;

What exactly happens when this code is executed? I am not getting any runtime errors or compiler warnings at all, the pointer still holds the same address before and after calling delete on it, however after delete trying to dereference or even cast it to int crashes the program sometimes but other time it just works, which kind of smells like undefined behavior.

0

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.