Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Compilers > Re: Null pointe...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 2340 of 2461
Post > Topic >>

Re: Null pointer analysis in C

by torbenm@[EMAIL PROTECTED] (Torben =?iso-8859-1?Q?=C6gidius?= Mogense Feb 25, 2008 at 11:48 AM

Naseer <naseer.naseer@[EMAIL PROTECTED]
> writes:

> What are the issues/problems of Null pointer in C and how they can be
> resolved "statically".  i.e. while doing static analysis(compile time)
> how can we find whether a pointer is null or not.

Such an analysis can only be approximate, as a precise determination
is equivalent to the halting problem.  You can choose which side you
want to err, so you can make an analysis that has no false positives
(but it will have false negatives) or an analysis that has no false
negatives (but it will have false positives).  You can, of course,
make an analysis that has both fasle positives and false negatives,
but you can't use this for much.

Some languages have type systems that distinguish pointers that can be
null from pointers that can't, and some of the languages have type
inference (so you don't have to specify this).  But the inference will
sometimes use "may be null" types for variables that can, in fact,
never be null, as this is the "safe" assumption: Optimisations that
depend on a pointer never being null (such as following the pointer
without testing for null) should not be applied to pointer that may be
null, but all you lose by not doing the optimisation on a variable
that can never be null is a little speed.  Some languages (like SML)
have as an invariant that pointers are never null (no program can ever
create a null pointer).  When compiling to an abstract machine (such
as JVM or .NET) that enforces null-pointer checks at every pointer
dereference, this knowledge can, however, not be exploited fully.

There are pointer analyses available for C which, in addition to
detecting aliasing, can also detect potential null-pointers.

	Torben
 




 3 Posts in Topic:
Null pointer analysis in C
Naseer <naseer.naseer@  2008-02-24 09:04:56 
Re: Null pointer analysis in C
"Diego Novillo"  2008-02-24 12:43:41 
Re: Null pointer analysis in C
torbenm@[EMAIL PROTECTED]  2008-02-25 11:48:05 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Jul 6 19:13:20 CDT 2008.