strlen is wrong because can not report if there is some error
strlen() has no way to report errors, according to its definition
in Standard C.
strlen() may well have no way to *detect* the error of an unterminated
string without causing undefined behavior (aborting the program with
a smegmentation fault, for example. And nobody said a smegmentation
fault has to be a catchable error).
you have right only if the programmer never make errors
are you a programmer of that kind?
How does one *detect* such an error? Especially if a + size_t max is
off the end of allocated memory?
if strlen sees some problem it has to report an error
That's not what Standard C says.
example return (size_t)-1 and not continue to run
It can either return or not continue to run; it can't do both.
if there is strlen(0); it has to report the error and not shut down
the system
That's not what Standard C says. And there's a difference between
shutting down the *program* (e.g. with smegmentation fault), and
shutting down the *system* (e.g. with blue screen of death or panic:
out of swap space).
So if i want to hang some of your pragrams i have just give a string
of size_t max len that has 1111111111111111111111111111111111111111
etc in it because for these string, there is the chance strlen should
result in an infinite loop (or ggets or fgets or what you want).
the idea is *all* functions should can to report errors if they see
these errors (and the programmer has to see if something goes wrong
until it is printf)
I'd be interested in how functions like exit() and abort() report errors,
and how a programmer checks for errors.