Bartc wrote:
"Eric Sosman" <esosman@ieee-dot-org.invalidwrot e in message
news:XImdnTItnK X_4I7VnZ2dnUVZ_ quhnZ2d@comcast .com...
>
>
I suspect this was written when there were already many implementations that
behaved this way.
news:XImdnTItnK X_4I7VnZ2dnUVZ_ quhnZ2d@comcast .com...
>Bartc wrote:
>>"Richard Heathfield" <rjh@see.sig.in validwrote
>>>The Standard requires that you pass to fclose a pointer to a stream
>>>object
>>>of type FILE. You did not do this. (0 doesn't point to any object at
>>>all,
>>>let alone a stream object.) You broke the rules, so all bets are off.
>>>The Standard requires that you pass to fclose a pointer to a stream
>>>object
>>>of type FILE. You did not do this. (0 doesn't point to any object at
>>>all,
>>>let alone a stream object.) You broke the rules, so all bets are off.
> The relevant passage is Section 7.1.4 paragraph 1:
>>
>"Each of the following statements applies unless
>explicitly stated otherwise [...]: If an argument to
>a function has an invalid value (such as [...] a null
>pointer, [...]) [...]the behavior is undefined. [...]"
>>
>"Each of the following statements applies unless
>explicitly stated otherwise [...]: If an argument to
>a function has an invalid value (such as [...] a null
>pointer, [...]) [...]the behavior is undefined. [...]"
I suspect this was written when there were already many implementations that
behaved this way.
language from whole cloth, but to codify existing practice insofar
as practical.
In the Rationale, the Committee laid out the principles that
it tried to apply when making decisions about the language. One
of these was "Keep the spirit of C," and the very first point in
the short list of facets that constitute that spirit is "Trust
the programmer." As Richard Heathfield pointed out earlier, trust
is not a one-sided relationship; the trusted party bears a burden
arising from the fact of being trusted.
If this was the case then it would be better to admit it rather than
suggest, as a few people have, that crashing on passing a null pointer is
actually a good idea.
suggest, as a few people have, that crashing on passing a null pointer is
actually a good idea.
If you want a hand-holding language (and there's no shame in wanting
such a thing), you can find plenty of them.
--
Eric Sosman
esosman@ieee-dot-org.invalid
Leave a comment: