This is still persisted in C ++. If your compiler complains as you describe for your first case, it is inappropriate.
To explain your second case, it is important to understand what is actually happening. An array type expression is implicitly converted to the corresponding pointer type, that is, T[n]
โ T*
. However, if T
itself is an array, this case is not handled specifically, and the decomposition between arrays and pointers does not extend. Thus, T*[n]
splits into T**
, but T[x][y]
will only fade to T[y]*
and no further.
From an implementation point of view, this makes sense, because further decay, if allowed, will produce T**
, which is a pointer to a pointer; whereas 2D C arrays are not implemented as jagged arrays (i.e., an array of pointers to arrays), they form a single continuous block of memory. So, there is no T*
"inside" of the array to accept the address to give you T**
. For permitted cases, a typical implementation simply takes the address of the array as a whole and converts it to a pointer type on one element (when the basic representation of the pointer is the same for all types, as it usually happens, this conversion is no-op at run time).
The normative reference here is ISO C ++ 03, 4.2 [conv.array] / 1:
The value of an lvalue or rvalue of type "array NT" or "array of unknown boundary T" can be converted to rvalue type "pointer to T". The result is a pointer to the first element of the array.
source share