[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: in-memory representation of NULL pointers?
From: |
Eric Blake |
Subject: |
Re: in-memory representation of NULL pointers? |
Date: |
Fri, 23 Apr 2010 11:41:51 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100330 Fedora/3.0.4-1.fc12 Lightning/1.0b1 Thunderbird/3.0.4 |
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.
>
> 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.
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature