This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: fopen(NULL) causes segmentation fault



# 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]