In standard C, you have a few options for declaring a function that accepts a pointer to a chunk of data:
void style_1(int * arr); void style_2(int arr); void style_3(int arr); void style_4(int size, int arr[size]); void style_5(int arr[static 10]); void style_6(int size, int arr[static size]);
The thing is, as near as I can tell, most of the "choice" is syntactic and doesn't contribute much to the program's actual meaning. The first three styles appear to be exactly equivalent, because "A declaration of a parameter as 'array of type' shall be adjusted to 'qualified pointer to type'" (C11 184.108.40.206 p7), and
style_4 is also the same for the purposes of the pointer parameter. For both
style_4, the array size is thrown away.
style_6 are actually different and impose a useful constraint, guaranteeing a non-null pointer with a minimum amount of storage. But why do we need to add a keyword to do this? The declarations of
style_4 seem to communicate just as much information to the reader. A compiler would surely have no problem with those, if only the language allowed them to be meaningful? As it is, this design choice seems to introduce a hole that can allow extra errors to slip through, by effectively instructing the machine not to check for them by default.
static added to impose the size constraint on array parameters in C? Why is the size on its own not sufficient?