$8.3.5 para 6 says "-6- If the type of a parameter includes a type of
the form ``pointer to array of unknown bound of T'' or ``reference to
array of unknown bound of T,'' the program is ill-formed.*
[Footnote: This excludes parameters of type ``ptr-arr-seq T2'' where
T2 is ``pointer to array of unknown bound of T'' and where ptr-arr-seq
means any sequence of ``pointer to'' and ``array of'' derived
declarator types. This exclusion applies to the parameters of the
function, and if a parameter is a pointer to function or pointer to
member function then to its parameters also, etc. --- end foonote]"
What I understand is that the following code is ill-formed
char buf[2][10];
void fn(char p[][], int size){}
int main(){
fn(buf, 2);
}
However what I understand from the Footnote is that the following
should be well-formed as part of the exclusion
char buf[2][10];
void fn(char (*p)[][], int rows, int cols){} // p is a pointer to an
array of unknown bounds
int main(){
fn(&buf, 10, 2);
}
However this also gives compilation error. Is my understanding of the
footnote wrong or is my code above wrong?
Regards,
Dabs.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
The above two examples are both ill-formed, since we have a simpler
rule in 8.3.4/p3, which says:
When several “array of” specifications are adjacent,
a multidimensional array is created; the constant expressions
that specify the bounds of the arrays can be omitted only for
the first member of the sequence.
Therefore, both "char p[][]" and "char (*p)[][]" are ill-formed.
Please note that array and adjacent "array-of"s are quite different,
usages apply to normal array does not apply to high order
array-of's at all.
HTH
Jiang