On 28.06.2020 20:16, Stefan Ram wrote:
> Richard Damon <Ric...@Damon-Family.org> writes:
>> Yes, in C we use the exact same syntax for a pointer to a single object,
>> and a pointer into an array of objects, and it is the job of the
>> programmer to keep this distinction clear (if he needs to).
>
> The importance of this distinction has perhaps been somewhat
> overemphasized in some recent posts to this newsgroup. When
> an expression has type "T*" and has a valid non-zero value at
> runtime, then it points to an object of type T. This is still
> true when this object happens to be some kind of subobject.
The way I use the term "valid" there are a very large number of valid
non-zero pointer values that don't point to objects.
The address after any array is a valid pointer value. There needs not be
any object there, or of the pointer's referent type. Additionally, for
the purpose of forming a pointer to a pseudo-object after, the C++
standard specifies that any single object can be regarded as an array.
Also, no valid function pointer points to an object.
Then, but this is only for C++, after the object that an object pointer
points to, has been destroyed, there is no object there. But until the
storage is deallocated there is storage that can be reused. And the
standard specifies how the pointer can be used for that.
As far as I know there is no commonly accepted reasonably short term for
"a pointer that points to an object", i.e. a pointer that can be
dereferenced (note: in C as I recall one can do `&*p` for a pointer to
beyond array). In my old C++03 pointers tutorial, which featured for a
time as reference in Wikipedia, I invented the awful name RealGood
pointer. Happily that term (and it's cousin URG, UnRealGood) never
caught on.
- Alf