Subject: Re: segmentation fault on fclose?
To: None <gillham@andrews.edu>
From: Charles M. Hannum <mycroft@gnu.ai.mit.edu>
List: current-users
Date: 09/04/1994 23:42:21
   Just two questions...  Should the following code cause
   a segmentation fault?

   #include <stdio.h>

   main()
   {
   FILE *fp;
   fp = NULL;
   fclose(fp);
   }

That's a matter of interpretation.  Note that the man page says:

SYNOPSIS
     #include <stdio.h>

     int
     fclose(FILE *stream)

DESCRIPTION
     The fclose() function dissociates the named stream from its underlying
     file or set of functions.  If the stream was being used for output, any
     buffered data is written first, using fflush(3).

i.e.  `stream' is a description of a stream.  There is no special case
for NULL.  ANSI does not require such a special case, and I really
don't like the idea of masking bugs in applications by kluging up the
C library.


------------------------------------------------------------------------------