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

Re: gcc and mint-libs PL46



If one of my programs calls fopen(NULL, "r"), then I *want* it to fail with
a bus error, so that I can debug it -- it should never be in a state where
it thinks a null pointer is valid data.

If GNU Chess is expecting that NULL is a valid string for any purpose at
all, then it's buggy. No doubt dereferncing location 0 works on many
operating systems (and probably usually results in an empty string), but
expecting this to always work is very bad programming practice.

As a parallel example, what should the library do for fopen(-1L, "r")?
-1L doesn't point to a valid path name; should fopen() then return NULL?
Or is it OK to crash? Carried to an extreme, we would have the library
catching all bus errors and trying to recover transparently. That may
not be a bad idea in some cases; but it would make debugging a real
nightmare.