>
> 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?
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
--
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


|