The answer to this question refers to this page which says that, in order for delete this;
to behave correctly:
You must be absolutely 100% positively sure that no one even touches the this pointer itself after the delete this line. In other words, you must not examine it, compare it with another pointer, compare it with
NULL
, print it, cast it, do anything with it.
I don't understand why touching the pointer itself causes problems.
Could someone please explain it to me?
It will probably work on most modern hardware, but it is undefined behavior. I believe the rationale (I read this somewhere online) is that some architectures have trapping capabilities in their pointer registers so if you load a pointer into a register and that pointer points to unallocated memory, the architecture might fire a signal.