Ticket #105 (NULL checks)

Andy Dougherty doughera at lafayette.edu
Wed Dec 31 20:03:56 UTC 2008


On Wed, 31 Dec 2008, Mark Glines wrote:

> Andy Dougherty wrote:
> > One trap:  If the gcc attribute_nonnull is still used for these same
> > functions, gcc can optimize away the NULL checks, rendering them useless.
> > I'd recommend also getting rid of the attribute_nonnull gcc checking.  I
> > have posted about this at length in previous RT tickets, if you need more
> > background.
> 
> Ok, I've gone and read through RT #49316 and RT #50684.  It sounds an awful
> lot like attribute_nonnull is an optimization, not a constraint as I had
> originally thought.  Therefore it's working against us, not with us.

I view it as a bit of both that, on balance, does indeed work more 
against than with us.

> I'm pretty sure assert() is a C library function.  Is gcc really smart enough
> (does it make assumptions about the behavior of this library function) to
> optimise it out?

In the usual implementation, assert(expression) is a preprocessor macro, 
so gcc really does see a simple test for whether "expression" is NULL, and 
really can optimize it away if it's been told that "expression" is 
guaranteed to be non-null.

-- 
    Andy Dougherty		doughera at lafayette.edu


More information about the parrot-dev mailing list