Do you truly have no neurons functioning
[snip]
That's about where I stopped reading. If you can't be civil, I'm just
not interested in what you have to say. It's too bad; there might
have been some interesting technical points in there, but I have
better things to do than wade through your crap.
There was an interesting technical point, and I'd be quite interested
to hear you and others talk about it, so I'll reproduce websnarf's
post with the gratuitous insults removed:
A pointer *ITSELF* is storage, which can be modified. By losing track of
this pointer value, logic errors can easily cause you to be pointing at the
wrong thing when you derefence that pointer. This is the source of danger.
An array is actually implicitely determined at runtime as a nonmutable
pointer that is never NULL -- if its auto, then its usually just an offset
relative to a stack register. The value cannot be modified at all, and its
storage lifetime is never in question or at issue.
Is an array really equivalent to a non-mutable non-NULL pointer?
It depends on what you mean by "pointer".
One common usage is to use the term "pointer" to refer to a pointer
*object*. In that sense, there is no pointer object associated with
an array object.
But if the term "pointer" refers instead to a pointer *value* (the
standard uses the term "pointer" this way), then yes, an array object
implies the existence of a pointer value which is non-mutable and
non-NULL. It is the pointer value to which the array name decays in
most contexts, the address of its first element.
Of course, arrays are not pointers and pointers are not arrays. Most
(but not all) operations on arrays in C are defined in terms of
pointer operations, but it's important to keep in mind that they're
very different things.
And if you've declared an array object, anything you do with it
outside the context in which it's declared (in the case of a VLA, this
is at most a single function) is likely to be done via pointers
anyway, with all the potential for mayhem that that implies.
As for an array object's storage lifetime being "never in question or
at issue", that's true if you know what you're doing, but we see
plenty of functions here that incorrectly attempt to return the
address of a local array object.
I'm not particularly happy with the way C sometimes conflates arrays
and pointers. But the underlying concepts are actually fairly
elegant, in an uncomfortably close-to-the-hardware kind of way. (This
is just my own personal opinion.) Reading and understanding section 6
of the comp.lang.c FAQ is a good way to cope with the confusion.
(This is not to imply that websnarf is or is not aware of all this.)