bug-gnulib
[Top][All Lists]
Advanced

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

Re: in-memory representation of NULL pointers?


From: Simon Josefsson
Subject: Re: in-memory representation of NULL pointers?
Date: Fri, 23 Apr 2010 20:04:07 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1 (gnu/linux)

Eric Blake <address@hidden> writes:

> On 04/23/2010 11:27 AM, Simon Josefsson wrote:
>> Not gnulib specific, but related to our coding style:
>> 
>> Does POSIX somewhere guarantee that the in-memory representation of NULL
>> pointers is 0?  I know that C89 doesn't make that guarantee, and that
>> some historic systems used non-0 memory values to represent NULL, but
>> I'm hoping that this is not permitted today by some standard.
>
> I think POSIX currently sticks by the same weasel-wording as C99, and
> allows a weirdnix system where the in-memory representation of NULL is
> not all 0 bits.

Darn.

>> I believe there is a bunch of places in gnulib which uses memset(P, 0,
>> sizeof(P)) to initialize structures containing pointers, which wouldn't
>> be OK if this is not the case.
>
> However, GNU Coding Standards states that we can assume that all
> platforms worth porting to obey the industry convention that NULL maps
> to all 0 bits, so even if POSIX doesn't guarantee it, gnulib is safe
> using the idiom.

Right.  The portability assumptions for a project becomes a bit more
complicated to explain though.

Thanks,
/Simon




reply via email to

[Prev in Thread] Current Thread [Next in Thread]