On Feb 9, Olumide wrote:
> > Hi,
>
> > I've been trying to figure out why the following bit of code does not
> > crash and still outputs the "Hello son" message althought its been
> > explicitly deleted. (BTW, I'm using the gcc 4.3.4 compiler.)
On 9 Feb., gwowen wrote:
> Calling methods on deleted objects is "undefined behaviour". *This
> means that anything is allowed, and nothing is guaranteed -- crashing
> is certainly one possiblity; behaving exactly as if you hadn't deleted
> the object is another possibility, in theory any other outcome is also
> possible (Usenet tradition demands that I add "including demons flying
> out of your nose" at this point). *Whatever your program does (or
> seems to do), it cannot be relied upon. *Next time you run the
> program, something else might happen.
Note that we exaggerate vastly in order to make it quite clear that
such errors should be avoided with paramount interest. Of course,
nothing as bad is going to happen if you stick to your particular
platform. However, should you ever consider moving to another platform
(or maybe just the next version of your compiler), you may be in for a
surprise.
Regards,
Stuart
|