c++/770: Memory allocated by new remains accessible even after calling delete.

Neil Booth neilb@earthling.net
Sat Nov 11 04:01:00 GMT 2000


Tathagato.Rai.Dastidar@nsc.com wrote:-

> After some time, it is destroyed by calling delete. However,
> data members of the class are still accessible via member
> functions (called on the deallocated pointer).

You've been lucky, then.

> Trying to access deallocated memory should give a core dump.

No, it's undefined behaviour.

> Nothing of the sort happens. The program runs normally.

This is not a bug; you just happen to have been lucky.  I bet if you
had the same line at other places in a program it would core dump.

I've closed the GNATS entry.

Neil.


More information about the Gcc-bugs mailing list