Eric Blake <ebl...@redhat.com> 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