In addition to optional type qualifiers and the keyword static, the [ and ] may delimit
an expression or *. If they delimit an expression (which specifies the size of an array), the
expression shall have an integer type. If the expression is a constant expression, it shall
have a value greater than zero. The element type shall not be an incomplete or function
type. The optional type qualifiers and the keyword static shall appear only in a
declaration of a function parameter with an array type, and then only in the outermost
array type derivation.
A declaration of a parameter as ‘‘array of type’’ shall be adjusted to ‘‘qualified pointer to
type’’, where the type qualifiers (if any) are those specified within the [ and ] of the
array type derivation. If the keyword static also appears within the [ and ] of the
array type derivation, then for each call to the function, the value of the corresponding
actual argument shall provide access to the first element of an array with at least as many
elements as specified by the size expression.
EXAMPLE 4 The following prototype has a variably modified parameter.
voidaddscalar(intn,intm,doublea[n][n*m+300],doublex);intmain(){doubleb[4][308];addscalar(4,2,b,2.17);return0;}voidaddscalar(intn,intm,doublea[n][n*m+300],doublex){for(inti=0;i<n;i++)for(intj=0,k=n*m+300;j<k;j++)// a is a pointer to a VLA with n*m+300 elementsa[i][j]+=x;}
ところで、このすぐ下にこんな例がある:
EXAMPLE 5 The following are all compatible function prototype declarators.
(Note that the last declaration also specifies that the argument corresponding to a in any call to f must be a
non-null pointer to the first of at least three arrays of 5 doubles, which the others do not.)
voidaddscalar(intn,intm,double(*consta)[n*m+300],doublex);// (snip)voidaddscalar(intn,intm,double(*consta)[n*m+300],doublex){for(inti=0;i<;n;i++)for(intj=0,k=n*m+300;j<;k;j++)// a is a pointer to a VLA with n*m+300 elements// i.e. *(a + i) is a VLA with n*m+300 elements(*(a+i))[j]+=x;}
と書けば、”a is a pointer to a VLA …” であって “a is a VLA …” ではないことが明瞭にわかる。