There are many endearing string functions in the C standard library, such as (in string.h)
char *strcat(char *str1, const char *str2);
or (in stdlib.h)
long int strtol(const char *nptr, char **endptr, int base);
(Ignore the wisdom of calling these functions, for the purposes of this question.)
What will happen if I pass any of these functions a NULL pointer? (I mean (char *) 0, not the empty string.)
I haven’t found any answers in the man pages or on the web.
This leads me to think it’s implementation-defined, but it could just as well mean an automatic segmentation fault; no special error behavior or return values are specified, either.
Could the behavior even vary from function to function, within the same implementation?
The C standard says it in 7.21.1 String Function Conventions, clause 2:
7.1.4 Use of library functions:
strcat()‘s description in 7.21.3.1 says nothing about the NULL pointer being a valid input, hence, I conclude, the behavior is officially undefined if any of its input pointers is NULL.