sint *f(int x)
s{
s return(&x); /* this address points to storage local of f() */
s}
s>
ssuch a returned pointer is ... invalid,
RPFalse, not in agreement. The pointer is valid. A pointer
RPcan point to anything. The value from the derefenced
RPpointer is invalid.
RP[...] it can be returned and assigned to another pointer
RPwithout being dereferenced...
Incorrect. There exist implementations (e.g. x86 architecture when
using far or huge data memory models and the AS/400) where
deallocation of storage causes the _values_ of any pointers to that
storage to become invalid. (Loading the value of the pointer into a
CPU pointer register causes a processor fault.) So simply using the
_values_ of the pointers, without even dereferencing them, causes
undefined behaviour. The C++ standard mentions this in regard to
storage with dynamic storage duration. The C standard is more general
and points out that the values of pointers to an object become
indeterminate after that object's lifetime, irrespective of storage
duration, ends.
s{
s return(&x); /* this address points to storage local of f() */
s}
s>
ssuch a returned pointer is ... invalid,
RPFalse, not in agreement. The pointer is valid. A pointer
RPcan point to anything. The value from the derefenced
RPpointer is invalid.
RP[...] it can be returned and assigned to another pointer
RPwithout being dereferenced...
Incorrect. There exist implementations (e.g. x86 architecture when
using far or huge data memory models and the AS/400) where
deallocation of storage causes the _values_ of any pointers to that
storage to become invalid. (Loading the value of the pointer into a
CPU pointer register causes a processor fault.) So simply using the
_values_ of the pointers, without even dereferencing them, causes
undefined behaviour. The C++ standard mentions this in regard to
storage with dynamic storage duration. The C standard is more general
and points out that the values of pointers to an object become
indeterminate after that object's lifetime, irrespective of storage
duration, ends.