On Wed, Mar 4, 2009 at 10:55 PM, John Matthews <[email protected]> wrote:
> --- In [email protected], Paul Herring <pauljherr...@...> wrote:
>>
>> <http://c-faq.com/null/machnon0.html>
>>
>> Don't rely on NULL being all bits zero.

Sorry - only 1/2 read the question...

> Sorry Paul - I don't see the bit that tells me whether static initialisation 
> to 0 means that pointers are set
> - to NULL independent of the internal representation, because the 
> initialisation is done in a pointer context, or
> - an internal 0 ie. not NULL on machines where NULL is internally non-0.

<http://c-faq.com/null/null2.html>

int fn2(void)
{
   static int *p;
   return !p;
}

This is an implicit null pointer constant since it's shorthand for

static int *p=0;

So the function will return 1 in all circumstances. No matter what the
internal representation of NULL, when used in a comparison it will
compare equal to (void*)0.

-- 
PJH

http://shabbleland.myminicity.com/ind
http://www.chavgangs.com/register.php?referer=9375

Reply via email to