This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: fopen(NULL) causes segmentation fault
- To: Andrew Wiseman <a dot wiseman at bandc dot dircon dot co dot uk>
- Subject: Re: fopen(NULL) causes segmentation fault
- From: Mo McKinlay <mmckinlay at labs dot interopen dot org>
- Date: Tue, 28 Mar 2000 19:24:14 +0100 (GMT)
- cc: gcc-bugs at gcc dot gnu dot org
# main()
# {
# long *file_rep = 0x0;
# fclose(file_rep);
# }
The fclose() function is provided by the C library, not by the compiler,
which is why Linux platforms cause a segmentation fault, and other
platforms do not (you may find that they set errno to EFAULT in this
case). In any case, you should take up the issue with the glibc people if
you believe the behaviour is incorrect.
Incidentally, you might find this useful: (taken from "(libc.info)Error
Codes"
- Macro: int EFAULT
Bad address; an invalid pointer was detected. In the GNU system,
this error never happens; you get a signal instead.
--
Mo McKinlay Chief Software Architect inter/open
mmckinlay@labs.interopen.org http://www.interopen.org