www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/10/15/05:57:07

Xref: news-dnh.mv.net comp.os.msdos.djgpp:2649
Path: news-dnh.mv.net!mv!news.sprintlink.net!in2.uu.net!usc!math.ohio-state.edu!news.cyberstore.ca!van-bc!unixg.ubc.ca!rover.ucs.ualberta.ca!news.ucalgary.ca!mewesolo
From: mewesolo AT freenet DOT calgary DOT ab DOT ca
Newsgroups: comp.os.msdos.djgpp
Subject: C++ delete []
Date: 15 Oct 1995 03:03:46 GMT
Organization: The University of Calgary
Lines: 26
Nntp-Posting-Host: mewesolo AT srv1 DOT freenet DOT calgary DOT ab DOT ca
Originator: mewesolo AT srv1 DOT freenet DOT calgary DOT ab DOT ca
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Dj-Gateway: from newsgroup comp.os.msdos.djgpp

I'm using djgpp 1.12 M4. As part of a learning exercise, I've defined a
class which allocates memory in the constructor, and deletes it in the
destructor. I've then defined a function which takes one parameter of this
class, and returns an object of the same class. The intent is to
deliberately break the code (I want to see what happens when I later free
which should already be freed memory, not to mention accesing this
memory).

Anyway, what I see is that the memory is freed twice with no problem, and
that the contents (a simple string) are still accessible. In other
words, it appears that delete [] is not doing its job (would we normally
expect a NULL pointer?). 

This may be related to an earlier post on realloc, etc...

I hope my explanation is clear enough. Remember that I'm trying to
induce an error. 

Thanks.


-- 
---------------------------------------------------------------------

Michael Wesolowski (mewesolo AT freenet DOT calgary DOT ab DOT ca)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019