S
spinoza1111
The traditional bug that not casting malloc() catches is when malloc()
is not declared (because the relevant #include is omitted) and thus
defaults to returning int. C's strong typing would normally catch
that error, but is defeated by the cast. That was why I used "int" in
my example.
That is completely absurd. I'll make a mistake in case I made a
mistake.
When you haven't made that mistake, the cast makes no difference
either way in terms of type safety.
It also seemed to me that Spinoza was asserting that casts are in
general a way to enforce strong typing, and I wanted to refute that.
I wasn't. C is a type-unsafe language, and jack shit can be enforced
in it. However, competent programmers when forced at gunpoint to use C
by criminals use cast in protest, primarily to document the intent of
their code for a post-C posterity to show that they haven't been
rendered completely mindless.
THE TRUTH IS THAT ALL PEOPLE ON EARTH ARE PUSHED BY TWO MEN INTO
PATTERNS THAT PLEASE THEM. THE PATTERNS SPELL OH NO NO NO BUT IT IS
NOT ENOUGH TO WRITE SYMBOLS. YOU MUST DO THE RIGHT ACTS WITH YOUR
BODY.
- Jenny Holzer, Laments