On Sun, 16 Oct 2016, Bernd Edlinger wrote:
> Second, the declaration in the glibc header files simply look wrong,
> because the type of argv, and envp is "char *const *" while the
> builtin function wants "const char**", thus only the array of char*
> itself is const, not the actual char stings they point to.
char *const * is the POSIX type. (It can't be const char ** or const char
*const * because you can't convert char ** implicitly to those types in
ISO C.) You'd need to check the list archives for rationale for the
built-in functions doing something different.
> Third, in C the builtins are not diagnosed, because C does only look
> at the mode of the parameters see match_builtin_function_types in
> c/c-decl.c, which may itself be wrong, because that makes an ABI
> decision dependent on the mode of the parameter.
The matching needs to be loose because of functions using types such as
FILE * where the compiler doesn't know the exact contents of the type when
processing built-in function definitions. (Historically there were also
issues with pre-ISO headers, but that may be less relevant now.)
Joseph S. Myers