Just about everyone reading this is probably familiar with these three key facts about C:
The C standard doesn't have a single word for this. It uses the word "conversion" when defining behavior (1) in 6.3.2.1p3, "equivalent" when defining behavior (2) in 6.5.2.1p2, and "adjustment" when defining behavior (3) in 6.7.6.3p7.
I am old-fashioned, and don't think there's anything wrong with calling this "array/pointer equivalence", provided it is clear in context that you are talking about expressions where (1) happens or function declarations where (3) happens. However, a more palatable term for the people who don't like "equivalence" would perhaps be "array-to-pointer conversion", since this confuses people most often when it's (1), I think.
This may seem like an abstract or philosophical question, so to frame it more concretely, what I'm looking for is is a simple noun or noun phrase I could use the sentence "Yes, due to _____, array subscription can be thought of as syntactic sugar for pointer arithmetic", in answer to, say, this question.
The Phrase you are looking for is "Yes, due to array subscribing being pointer arithmetic under the hood, array subscribing can be thought of as syntactic sugar for pointer arithmetic."
Which is of course, silly, because the reason for saying that array subscribing is syntactic sugar for pointer arithmetic is because that is exactly what it is, it does not require further explanation unless the person you are saying this to either does not know what 'array subscribing', 'pointer arithmetics' or 'syntactic sugar' mean. This is not to say the compiler does not know the difference of the two (it does because it is the one who is responsible for all the syntactic sugar you're getting as a result of that).
This same question could be raised about everything that any language does for us which we could do ourselves by using a higher number of lower level instructions and as such being able to refer to it using multiple terms that only change the amount of syntactic sugar used. The whole point is not to pretend like they are different (they always are in way, but that's not the point), but to make programming easier (just think about writing code without having the [] operator as syntactic sugar for pointer arithmetics, and you quickly realize the reason for its existence - it's not because it's different, it's because it's easier to write, read and manage).
(But please note that I am not looking for answers to that question, or for answers to the question "What's wrong with the word 'equivalence'?". Yes, I know, it can mislead learners into imagining that arrays and pointers are somehow the same. I did have that in mind when I wrote this FAQ list entry.)
Your question seems to be "What's a modern term for array pointer equivalence in the sense that array subscription is just syntactic sugar for pointer arithmetics?"
The answer is:
There is no single name given to the three concepts mentioned, but I think describing them as implying any sort of "equivalence" is counter-productive, at least when describing "modern" C. While the results of array decay generally behave like pointers, C99 specifies that the pointers yielded by array decay are not required to be behave in the same way as pointers achieved via other means. Given:
char fetch_byte_at(void *p, int x) { return ((char*)p)[x]; }
struct {char arr[5][7];} s;
char test1(int x) { return s.arr[0][x]; }
char test2(int x) { return fetch_byte_at(&s, x); }
the Standard doesn't directly specify any reason why pointer value s.arr[0]
used in test1
should not be equivalent to the pointer value ((char*)(void*)s)
used when fetch_byte_at
is called from test2
. It does, however, simultaneously imply that test2
should be able to read out all the bytes of s
[implying that it should work predictably with values of x
up to at least 34] while saying that s.arr[0][x]
is only meaningful for values of x
up to 6.
While nothing in the Standard would contradict either of your first two points individually, it's not possible for both to hold. Either the result of an array decay is something other than an "ordinary" pointer to the array's first element, or applying the []
operator to an array has different semantics from applying it to a pointer. While it's unclear which of #1 and #2 has been invalidated by C99, they no longer together form any kind of "equivalence" in modern C.
If you recognize a distinction between traditional C and "modern" C, it might be useful to establish terms for the things that make the former useful. Such things go beyond the points you mention, however. Unfortunately, I don't know of any standard terms for such things, and would not look for the Standard to supply such terminology when it no longer supports the concepts involved.
I suggest "array-to-pointer decay" is a reasonable shorthand, since "decay" is commonplace jargon in referring to the type conversion, with precedent elsewhere in the C FAQ: Question 6.12:
Q: Since array references decay into pointers, if arr is an array, what's the difference between arr and &arr?
An extended technical meaning of "decay" that includes this one has been adopted into C++ Standard Library nomenclature since C++11: std::decay
This is a subtle question. Upon browsing an English thesaurus and dictionary, I came to find that the term similitude might be appropriate for your context.
By Oxford's Online Dictionary definition, the word Similar
is defined as:
having a resemblance in appearance, character, or quantity, without being identical.
and the word Similitude
as:
the quality or state of being similar to something.
Since arrays and pointers are not identical, but are sometimes treated similarly, we might say:
Yes, due to Array/Pointer similitude, array subscripting can be thought of as syntactic sugar for pointer arithmetic"