🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3776

Re: Using pointers after delete

#3776
From: Eric Newhuis
Date: Fri, 22 Mar 1996 06:54
26 lines
1723 bytes
joe (j.) halpin wrote:
> 
> char *pc = new char[128];
> delete pc;
> pc = 0;
> 
> Am I misunderstanding something, or is it illegal to zero out pointers
> after they've been deallocated? I'm assuming that the intent was to
> disallow dereferencing of pointers that have been handed to
> delete. The wording seems to disallow the above as well.
> 

There is not problem using a pointer like that.  If you re-read the 
working paper closely you'll notice that the following phrase:

"An invalid pointer con-tains an unusable value:  it cannot even be used 
in an expression."

is refering to the value of the pointer, not the pointer itself.  In 
other words, replacing the value with zero is fine.
---
[ 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         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
Technical Details
Message-ID: <31523072.69D3@ix.netcom.com>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <4irkhs$8al@crchh327.rich.bnr.ca>

Show Full Headers
Complete Article Headers
From: Eric Newhuis <newhuis@ix.netcom.com>
Message-ID: <31523072.69D3@ix.netcom.com>
X-Original-Date: Thu, 21 Mar 1996 22:45:38 -0600
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 22 Mar 96 06:54:35 GMT
Approved: fjh@cs.mu.oz.au
Newsgroups: comp.std.c++
Subject: Re: Using pointers after delete
Organization: FutureSource
References: <4irkhs$8al@crchh327.rich.bnr.ca>
X-Netcom-Date: Thu Mar 21  8:47:58 PM PST 1996
X-Mailer: Mozilla 2.0 (Win95; I)
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMVJOt+EDnX0m9pzZAQEqPAF/cX9rCL+V3TRwHJ2GsetvBqOSAZ5OSANh
 iIUkW8Ze0Bq2ZcQUzVC9gs7RNMBOMbo/
 =OCOb