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

Re: easy to miss bug (even in structured debug)



> From mark Mon Nov 20 20:20:48 1989
> 
>    Date: Mon, 20 Nov 89 14:11:09 PST
>    From: tribble (Eric Dean Tribble)
> 
>    I occasionally worry about bugs resulting from passing NULL pointers
>    rather than pointers to objects.  The 'fetch' operations make this
>    especially easy.  I check these by considering the types {Foo *|NULL}
>    different from {Foo*} when I walk through the code in my mind.
> 
>    []Can we add this stronger type-checking in xlint?
> 
> []  I think this is probably easy (or at least possible) to XLint for.

I think it is probably quite hard.  Example:

sub(p)
  T *	p;
{
	if (p == NULL) {
		SubTakingNULL(p);
	} else {
		SubTakingOnlyT(p);   /* What would XLint think of this? */
	}
}

Now expand that for T1, T11, T2, etc...  XLint must be VERY smart
to figure out what could happen.  I suspect it might have to solve
the halting problem in the general case.  Throwing up its hands when
things get too screwy for it is ONLY good enough IF the special cases
it CAN handle are sufficiently general.

	michael