T
Tim Rentsch
Richard Heathfield said:Kaz Kylheku said:
[snip]
Then there is this curiosity:
7.1.4 [ ... ] If a function argument is described as being an
array, the pointer actually passed to the function shall have a
value such that all address computations and accesses to objects
(that would be valid if the pointer did point to the first
element of such an array) are in fact valid.
Right. The point here, as far as I can see, is that what is passed
to the function is a pointer, not an array. I find the
parenthetical comment to be bizarre, since the pointer /does/ point
to the first element of the array!
The point of the comment is that the (pointer) value actually passed
must be able to accept all the address calculation and object accesses
the function requires of it, without undefined behavior. That needn't
be every element of an actual array.
Also, re: the parenthetical comment -- even if the value actually
passed points to an array, that array might not be large enough to
match what's needed for the function specification; "such an array"
is one matching the function's requirements. And, the value actually
passed doesn't have to point to the first element (or any element) of
an actual array -- the argument value could point one past the end of
an array, or even be NULL. Perhaps I should have said at the
beginning -- the phrase "a function argument is described ..." is
talking about the argument /required/, not about what argument value
is actually /provided/. Does that make more sense now?