TH>> Actually, the pointer *exists*, but the stack frame
TH>> probably is clobbered. The result is the same, no string.
KK>> Right. It's a valid address, but it is Wrigley Field.
KK>> Jake and Elwood aren't there. ( Blues Brothers Reference )
TH> [grin]
It should be noted that Standard C++ *doesn't* guarantee that a pointer that
has been passed to free() or delete[] is valid afterwards, and even implies
that use of the *value* of such a pointer (i.e. *without* applying the
indirection operator) will result in undefined behaviour.
This is to allow C++ implementations on hardware architectures such as the
AS/400, or Intel compatible CPUs running in 16-bit protected mode, where
returning memory to the operating system, via the Standard Library, results
in an address that cannot be loaded into the CPU's registers without causing
an exception.
Non-segmented archtectures, such "flat model" 32-bit protected mode C++
implementations on Intel compatible CPUs, are more forgiving, and generally
one can get away with using a pointer value after passing it to free() or
delete[] on such architectures, but that doesn't change what the C++ Standard
actually *says*.
¯ JdeBP ®
--- FleetStreet 1.19 NR
---------------
* Origin: JdeBP's point, using Squish (2:440/4.3)
|