>On Thursday 22 March 2007 15:42, [EMAIL PROTECTED] wrote: >> >> getc(NULL) also blows up; what is your point? >> > >> >My point is that it should not SEGV on NULL pointer. It should >> >return -1 and set EBADF. >> >> You are wrong; the standard disagrees with you. > >7.19.7.5.3: > >The [getc] function returns the next characted from the input stream >pointed to by [stream]. If the stream is at end-of-file, the >end-of-file indicator for the stream is set and [getc] returns EOF. >If a read error occurs, the error indicator for the stream is set and >[getc] returns EOF. > >Where does the standard disagree ?
You quoted a very narrow bit of the standard. But even from this bit you can tell that you are wrong; it is talking about a [stream]. You don't pass a [stream]. You pass NULL. Tell me, how does one set the error indicator on NULL? What possible sense does the first sentence make when you evaluate "input stream pointed to by NULL"? It's for this reason that standards spend some time discussing undefined behaviour; the behaviour of getc is defined *when you pass a stream*. You don't pass a stream, then you don't play and the definition of getc() is irrelevant. Casting something to FILE * does not magically make them streams. Casper _______________________________________________ opensolaris-discuss mailing list [email protected]
