Wrong.
The major reason for not using superfluous casts, of which malloc()
casts are only the most common category, is that it damages the
programmer's ability to treat a cast as a warning sign.
So says the received opinion. Personally, I prefer the type safety
that comes from me asserting the type of object allocated on the RHS,
and letting the compiler enforce.
To me,
malloc(unsigned_num_elements * sizeof(type_t))
has an implicit type of type_t*. I cast to make that explicit, and
then the compiler can catch type errors. History has shown that I am
more likely to make those kind of mistakes than forget to prototype
malloc, and my compiler checks for missing prototypes anyway. I don't
need the (minor, nebulous) benefits of not casting pointing out. I
understand them well enough, thank you. I prefer the (minor,
nebulous) benefits of casting, thanks. Experience has shown that that
is what works for me. On matters of taste, it is possible to have
thought it through, and reached a different conclusion from the
majority, you know.
If you don't think like that, fine. If you don't make those errors,
lucky you, well done. But its idiotic to pretend your personal
preference is some sort of hard and fast rule that enables you to tell
good programmers from bad. It's a guideline, not an article of faith.
However, since so many people clearly think that way, may this will
makes you feel better and stop the mouths from foaming:
You're way is the one true way. I'm completely wrong, I repent.
yadda yadda yadda.