Re: Little code cleanup
On Mon, Mar 03, 2008 at 11:08:34PM -0500, Derek Martin wrote:
> On Tue, Mar 04, 2008 at 12:26:23AM +0100, Vincent Lefevre wrote:
> > On 2008-03-03 17:42:01 +0100, S?bastien Hinderer wrote:
> > > 2. It is true that testing pointers may avoid segfaults, but they don't
> > > avoid problems.
>
> That really depends on whether the code is written such that it knows
> whether the pointer should ever be null, and how the programmer decides
> to deal with it when it is... What you say is true sometimes, but
> untrue often (if the code is well-written). If the programmer can
> know, for instance, that a null pointer in a particular place is
> clearly a bug, then he could, for example, log a line to wherever
> (stderr, some log file, etc.) which tells you what function was
> executing when it happened (though this is tedious to maintain), what
> source file and line number
Actually these are often easier to debug is the program is allowed
to take the SIGSEGV and core dump.
Systems that convert segfaults to C++ exceptions make them almost
impossible to debug.
David
--
David Laight: david@xxxxxxxxx