An array type decays to a pointer type when it is passed to a function
That means in
int func(int x[*p])
*p should not be evaluated as the declaration is equivalent to int func(int *x)
Does the same hold for pointer to arrays?
Here is the code
int *p=0;
void func(int (*ptr)[*p]) //A
{
// code
}
int main()
{
int arr[5][5];
func(arr);
}
Is evaluation of *p at //A guaranteed by the Standard?
I tried with and without optimization on g++4.6. With optimizations enabled I don't get segfault. On clang the code is not giving any segfault even without any optimizations.
void func(int (*ptr)[*p])exactly the same asvoid func(int *ptr[])?void func(int x[RANDOM_STUFF])was valid!