This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/770: Memory allocated by new remains accessible even after calling delete.
- To: Tathagato dot Rai dot Dastidar at nsc dot com
- Subject: Re: c++/770: Memory allocated by new remains accessible even after calling delete.
- From: Neil Booth <neilb at earthling dot net>
- Date: Sat, 11 Nov 2000 12:01:47 +0000
- Cc: gcc-bugs at gcc dot gnu dot org
- References: <20001111054432.27267.qmail@sourceware.cygnus.com>
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.