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: Pádraig Brady
Subject: Re: in-memory representation of NULL pointers?
Date: Sat, 24 Apr 2010 12:14:03 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3

On 23/04/10 23:51, Paul Eggert wrote:
>>>> 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.
> 
> If you want something portable, which will work even on the weird
> machines that don't use all-zero-bits for null pointers, you can use
> something like the DECLARE_ZEROED_AGGREGATE macro of
> coreutils/src/system.h.

The awkward macro is required to suppress warnings.
I've asked gcc to relax that particular warning as referenced here:
http://www.pixelbeat.org/programming/gcc/auto_init.html

cheers,
Pádraig.




reply via email to

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