From -544249525749311185
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,176c9dc06a6729eb
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2002-03-25 13:47:02 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!colt.net!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: John Nagle <nagle@animats.com>
Newsgroups: comp.std.c++
Subject: Re: why doesn't delete NULL the pointer?
Date: Mon, 25 Mar 2002 21:46:52 GMT
Organization: Prodigy Internet http://www.prodigy.com
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <3C9F938C.5060805@animats.com>
References: <a7j7vg$78s$1@watserv3.uwaterloo.ca> <3C9DD892.94860335@acm.org> <a7lhfq$co1$1@eeyore.INS.cwru.edu> <EmhE+IDVkln8Ewj$@robinton.ntlworld.com>
X-Trace: mail2news.demon.co.uk 1017092816 mail2news:25447 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1
X-Accept-Language: en-us
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Date: Mon, 25 Mar 2002 15:57:36 EST
X-UserInfo1: Q[R_PJSCTS@QBQLXCJKL^_TDEB\@PD\MNPWZKB]MPXHBTWICYFWUQBKZQLYJX\_ITFD_KFVLUN[DOM_A_NSYNWPFWNS[XV\I]PZ@BQ[@CDQDPCL^FKCBIPC@KLGEZEFNMDYMKHRL_YYYGDSSODXYN@[\BK[LVTWI@AXGQCOA_SAH@TPD^\AL\RLGRFWEARBM
Lines: 46
Xref: archiver1.google.com comp.std.c++:10186

Francis Glassborow wrote:

> In article <a7lhfq$co1$1@eeyore.INS.cwru.edu>, Ken Alverson 
> <Ken@Alverson.com> writes
> 
>> I can't see how it would be *more* dangerous than not setting it to NULL,
>> but I agree that *relying* on it being NULL would be a bad idea.
> 
> 
> It is easier to teach people a simple rule (and a simple solution) such as:
> 
> It is your responsibility to null a pointer when the object it points to 
> has been deleted. Rather than say, sometimes the compiler will do it but 
> now you must learn when it won't.
> 
> And the solution? Well learn to use handles and smart pointers.


     Handles and smart pointers don't work very well in C++.
The language doesn't support them adequately.  Even
the simplest case, auto_ptr, can't be made safe.
People have tried hard on that one, and the
semantics of auto_ptr we have now are, at best,
mediocre.

     We went through this back when I was proposing
"strict C++".  It can be done, but not with total
backwards compatibility.

     The C/C++ attitude that the language and compiler
have no responsibility for memory integrity is the
single largest cause of production defects in programs
today.  Look at Bugtraq.   It's also one of the main
motivators for transitioning to Java and various
scripting languages.

				John Nagle
				Animats


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]



