[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gcc and mint-libs PL46



>> >> fopen( NULL, "r" );

>> >Dereferencing a NULL pointer is not portable, so it's not a library bug.
>> >You'll get the same result on many UNIX systems.

>> But it could be argued the fopen library code should check for a NULL
>> filename and return a NULL pointer.

>Well, what does the ANSI spec say? Surely that's the arbiter in this case..

ANSI/ISO 7.9.5.3 describes fopen(), saying (with text in <>'s typeset in
fixed font):

|The <fopen> function opens the file whose name is the string pointed to
|by <filename>, and associates a stream with it.

Nowhere in 7.9.5.3 does it mandate behavior in the case filename==NULL,
and NULL by definition does not point to a string; I intrepret this to
mean that NULL is an invalid value for <filename>, and the behavior is
therefore undefined by 7.1.7.  So the library is allowed but not
required to check for this.

						-sbigham