X
Xavier Roche
Hi folks,
I've never really used fixed-size char[] inside function argument list ;
ie. as in:
static void foo(char bar[32]) {
strcpy(bar, "foo");
}
... but I was expecting to get at least a warning when using it as in:
char foo[32];
foo(&foo[1]);
(tested with GCC with -W -Wextra -pedantic)
Aren't the types different ? Or did I obviously miss something
ridiculously trivial ?
My own explanation is that in this case "bar" is NOT of type char[32]
but char* (probably because the array is not copied when calling the
function, but its pointer is) [somehow confirmed by the fact that
sizeof(bar) equals sizeof(char*), and not 32*sizeof(char) ...]
Can a standard specialist confirm this (rather trivial) ?
I've never really used fixed-size char[] inside function argument list ;
ie. as in:
static void foo(char bar[32]) {
strcpy(bar, "foo");
}
... but I was expecting to get at least a warning when using it as in:
char foo[32];
foo(&foo[1]);
(tested with GCC with -W -Wextra -pedantic)
Aren't the types different ? Or did I obviously miss something
ridiculously trivial ?
My own explanation is that in this case "bar" is NOT of type char[32]
but char* (probably because the array is not copied when calling the
function, but its pointer is) [somehow confirmed by the fact that
sizeof(bar) equals sizeof(char*), and not 32*sizeof(char) ...]
Can a standard specialist confirm this (rather trivial) ?