Subject: Re: segmentation fault on fclose?
To: Charles M. Hannum <mycroft@gnu.ai.mit.edu>
From: grantham <grantham@amalthea.tenon.com>
List: current-users
Date: 09/04/1994 22:14:09
Andrew Gillham:
>    Just two questions...  Should the following code cause
>    a segmentation fault?
[...]
>    fp = NULL;
>    fclose(fp);
>    }

Charles Hannum:
> 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.

In this case, Andrew, I'm pretty sure an application would only
call fclose() with NULL if it had lost track of that stream pointer.
As Charles does, I would certainly consider this an error in
the program, not in the C library.  I considered advocating checking
for NULL in fclose, but it occured to me I would actually rather
that my program dump core, as a warning to me that I was closing
a file twice, closing a file that was never open, or somehow not
handling a file correctly in some other way, rather than blindly
continue on.  I would consider that segmentation fault to be a
debugging aid.

		-Brad
-- 
Brad Grantham, grantham@netcom.com >+------+< Happily slaved to NetBSD/Mac68k!
MacBSD : II, IIx, IIcx, IIci, SE/30, IIsi, IIvx -- The list is growing...

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