Article View: comp.std.c++
Article #3763Re: Referencing pointers after delete
From: Tom Payne
Date: Thu, 21 Mar 1996 19:19
Date: Thu, 21 Mar 1996 19:19
37 lines
2583 bytes
2583 bytes
joe (j.) halpin (jhalpin@bnr.ca) wrote:
: To Moderator: This may be a duplicate, my newsreader software was having
: trouble sending this, so I'm mailing it as well.
:
: 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.
[...]
: 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.
:
: In fact, it sounds like it also rules out things like 'if(pc == 0)
: ...' after the above fragment.
Apparently there are architectures (80386?) that perform such validity
checks on read access to pointer registers and trap on certain bogus
values. So, the standard deems that after deallocation a pointer
object might contain a value that is so bogus that even reading it
will provoke "undefined behavior" and assigning the pointer a valid
value is the only valid operation. It seems that to accomodate
certain hardware-based validity checkers for pointers, the standard
has precluded the possibility of portable software-based validity
checking. IMHO an unfortunate decision.
Tom Payne (thp@cs.ucr.edu)
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Technical Details
Message-ID:
<4is60i$ft6@galaxy.ucr.edu>Path:
arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austernReferences:
<4is05t$ceo@engnews1.Eng.Sun.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austern From: thp@cs.ucr.edu (Tom Payne) Newsgroups: comp.std.c++ Subject: Re: Referencing pointers after delete Date: 21 Mar 1996 11:19:11 PST Organization: University of California, Riverside Approved: austern@isolde.mti.sgi.com Message-ID: <4is60i$ft6@galaxy.ucr.edu> References: <4is05t$ceo@engnews1.Eng.Sun.COM> NNTP-Posting-Host: isolde.mti.sgi.com X-Original-Date: 21 Mar 1996 18:09:22 GMT X-Newsreader: TIN [UNIX 1.3 950824BETA PL0] X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBMVGrwUy4NqrwXLNJAQEkcQIAiE4YCLheIHih3c+w5NtfJpOly/eLUuiH dCUcvI6m1UZ6KhkvAs3T3jNM9DlaX9+LbX6m/BDE3DjOaOwYnX+0XA== =CrZA Originator: austern@isolde.mti.sgi.com