Expert C Programming: Deep C Secrets https://www.amazon.com/dp/0131774298/
A little dated, still lots of relevant knowledge though.
Expert C Programming: Deep C Secrets https://www.amazon.com/dp/0131774298/
A little dated, still lots of relevant knowledge though.
An especially memorable part for me was how it took 3 pages of language lawyering to explain why this doesn't compile:
foo(const char **p) { }
main(int argc, char **argv)
{
foo(argv);
}It takes quite a bit to explain because the "common sense" is that if one level of pointer indirection allows you to pass non-const where const is expected, then two levels shouldn't be any different. But common sense is wrong, and the compiler is right. And it doesn't require any language lawyering, either - all you need to do is slightly tweak the example to show why exactly it is unsafe.
Now, it is not undefined behavior for the function to not return anything despite having a return type. It is UB for the caller to try to use the returned value, but in this case it's not actually used.
The implicit int feature is really very much deprecated (in fact, it was already removed in C99, almost 20 years ago!). If, for some mysterious reason, you're trying to compile code like that, it's probably very old code dating to before C was an ANSI standard, and void return type was a thing. In such code, it would be pretty common for functions to not return anything, because semantically they don't - it was just a quirk of the language that there was no notion to express a non-value-returning function back then, and so returning an (undefined) int became idiomatic. In C89, this entire behavior was retained largely because backwards compatibility was necessary. C99 finally fixed it.