🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Referencing pointers after delete

#3768
From: joe (j.) halpin
Date: Fri, 22 Mar 1996 02:02
49 lines
2358 bytes
In article <4isca2$t20@news.BelWue.DE>,
Dietmar Kuehl <dietmar.kuehl@uni-konstanz.de> wrote:
>Hi,
>
>joe (j.) halpin (jhalpin@bnr.ca) wrote:
>: In 3.7.3.2.4 the January working paper says:
>
>: 4 A deallocation function can free the storage referenced by the pointer
>:   given  as  its  argument and renders the pointer invalid.  The storage
>:   can be made available for further allocation.  An invalid pointer con-
>:   tains an unusable value:  it cannot even be used in an expression.
>
>: This sounds as though, in the following:
>
>: char *pc = new char[128];
>: delete pc;
>: pc = 0;
>
>: it makes the final assignment (an expression) invalid.
>
>No. You cannot use the value of the pointer but you can use the pointer

So, in the sentence above - "An invalid pointer contains an unusable
value:  it cannot even be used in an expression." - the word 'it'
refers to the value and not the pointer? That makes sense, although
the phrasing is a bit ambiguous.

>(actually, you get undefined behavior in the code above because you
>delete an array object with 'delete' instead of 'delete[]'; I assume

Mea culpa.

[...]

Thanks

Joe
-- 
Joe Halpin                             jhalpin@nortel.com
Nortel Wireless                        (214) 684-5657 
Richardson, TX  75083-3871             <standard disclaimer applies>
-------------------------------------------------------------------------------

---
[ 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: <4iss70$82f@crchh327.rich.bnr.ca>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back

Show Full Headers
Complete Article Headers
From: "joe (j.) halpin" <jhalpin@bnr.ca>
Message-ID: <4iss70$82f@crchh327.rich.bnr.ca>
X-Original-Date: Fri, 22 Mar 1996 00:28:16 +0000
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 22 Mar 96 02:02:01 GMT
Approved: fjh@cs.mu.oz.au
Subject: Re: Referencing pointers after delete
Newsgroups: comp.std.c++
Organization: Bell-Northern Research, Richardson, TX
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMVIKSuEDnX0m9pzZAQGFNAF9FadegeWAJQ5D0E/0lNpBKRJAL1/NyKfk
 5n5fa96+ZbiBSwHSh8g2P+JvoduVpHXk
 =de/9