
Why not cast the rerurn from malloc()?
Quote:
>>>And the list of compilers which won't detect it is...?
>>...depressingly long. Even "gcc -ansi -pedantic" silently swallows it.
>Yes, it "even swallows it" in minimum warning mode.
This is far from "minimum warning" mode.
Quote:
>>Nonsense. It solves a very real problem, and actually involves *less*
>>work than doing it the inferior way. You only have to look back a few
>>weeks in this group to find several postings by people bitten by the
>>"failure to include stdlib.h" error and who had failed to spot the
>>problem *precisely because* they had cast the result of malloc. (And this
>>is since the last time you claimed it didn't solve a real problem.)
>There have been no such postings.
Now why would you say such a silly thing? Anyone with access to DejaNews
Quote:
>If you had read the postings properly
>you would perhaps have understood the nature of the code and that they
>had in fact spotted the error *despite* the cast.
Ah, the Longstreet argument. "If you disagree with me it's because
you don't understand." Well if you care to go back and *read what I
wrote* it will be clear that I did fully understand the nature of the code.
It will also be clear the poster had not spotted the error (or indeed
he wouldn't have posted asking for an explanation) and had the cast been
missed out the other compiler would also have pointed out the error.
Both your assertions in the above paragraph are thus false.
Quote:
>>Code of the second type is depressingly common. You may not write it and
>>I certainly don't, but it does exist in very large quantities. Your method
>>is then totally useless, but the recommended technique of not casting
>>the result of malloc *continues to work* and works well. What's more it
>>doesn't cost you anything and actually involves less typing.
>You actually believe deleting thousands of casts is easier than adding
>the prototypes?
Where did I suggest going through deleting casts (or for that matter,
not adding prototypes)? This is a pathetic form of argument - pretend
your opponent said something silly which he didn't say, then point out
it's silly. You lose again.
Quote:
>And you also believe that the code will be correct just
>by deleting the casts?
No. Second attempt at using deceptive argument technique. Failed again.
Quote:
>What language are you talking about?
C. This newsgroup is for the discussion of the C programming language.
Quote:
>I really don't have the patience to argue with you over your religious
>beliefs.
Ah, not only the Longstreet technique but also the Nudds approach - "If
you disagree with me then it's due to your religious beliefs". Sorry,
that one doesn't wash either.
Quote:
>The casts are a matter of stylistic preferences.
Indeed. No-one has suggested otherwise, but missing them out is a win-win
option so it's a good stylistic approach to adopt.
And as far as I'm concerned, that's the end of the thread for me. Unless
you can come up with any real disadvantages of the approach which don't
involve mythical languages I won't respond to any more of your attempts
to obfuscate the issue.
John
--
John Winters. Wallingford, Oxon, England.
The Linux Emporium - a source for Linux CDs in the UK
See <http://www.polo.demon.co.uk/emporium.html>