 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
kanze@gabi-soft.fr Guest
|
Posted: Tue Dec 07, 2004 4:45 am Post subject: Using the pointer after delete |
|
|
[email]pal_ari (AT) yahoo (DOT) co.in[/email] (Arijit) wrote in message
news:<31fg2fF393a33U1 (AT) individual (DOT) net>...
| Quote: | James Kuyper wrote:
Note: what you're doing doesn't tell us whether the value of 'p'
changed; it can only tell us whether the representation of 'p'
changed. There's a mapping between representation and value, and
that mapping can change as the result of the execution of a delete
expression. I don't believe that 'delete p' is allowed to change the
representation, but I'm sure it can change the value.
If the bitwise representation of two objects are the same, how can
their values be different ?
|
The value of an object is an interpretation of the bitwise
representation. To start with, it depends on the type: you'd certainly
agree that the value of the same bitwise representation will differ
depending on whether the type is a float or an int. In this case, we
have an object whose value is undefined, and for which accessing the
value is undefined behavior. The object's memory is still allocated,
however, the bits are there, and we can still access the bitwise
representation by means of the standard C++ techniques for accessing
bitwise represntations.
Or at least, that's what I've always thought. Andy Koenig seems to
think otherwise, and until he's presented his reasons, I'll reserve
judgement.
| Quote: | I am assuming that you are not referring
to paging, because that works transparently to the program anyway.
An example demonstrating your point would help.
|
An obvious example would be copying a float into an unsigned int on the
majority of 32 bit machines around today. The bitwise representation of
the two objects will be the same, but the value surely won't be (unless
the float happened to contain a positive 0.0).
The trick with the pointer is that the raw memory (the bitwize
representation) still exists, even if the value of the pointer is
invalid (doesn't exist, in a way, since you can't access it).
--
James Kanze GABI Software http://www.gabi-soft.fr
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|