Re: fclose(0)
Bartc wrote:
The type is acceptable, but the value is not. Would
you expect `fprintf (NULL, "Hello, world!\n");' to work?
How about `fprintf (NULL, NULL);'?
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. [...]"
--
Eric Sosman
esosman@ieee-dot-org.invalid
Bartc wrote:
"Richard Heathfield" <rjh@see.sig.in validwrote
>
fopen() returns a FILE* value, which can include NULL. So it's argueable
that NULL (or (FILE*)NULL) is acceptable, type-wise, to fclose().
>>
>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.
fopen() returns a FILE* value, which can include NULL. So it's argueable
that NULL (or (FILE*)NULL) is acceptable, type-wise, to fclose().
you expect `fprintf (NULL, "Hello, world!\n");' to work?
How about `fprintf (NULL, NULL);'?
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. [...]"
--
Eric Sosman
esosman@ieee-dot-org.invalid
Comment