On 05/05/2017 12:18 PM, Eric Blake wrote:
> On 05/05/2017 12:07 PM, Richard W.M. Jones wrote:
>> Eric, what do you think of Pavel's analysis and/or suggested fix
>> below? It seems all too plausible to me unfortunately :-(
>>
>>> There NULL is macros which can be defined as 0 or (void*)0, again in
>>> accordance with c99:
> C99 permits:
> #define NULL 0
>
> but POSIX does not. POSIX _requires_
>
> #define NULL ((void*)0)
>
> or the equivalent, so that NULL is properly typed as a pointer to void
> in ALL cases (rather than the weaker C99 solution of letting the integer
> zero constant leak), in part _because_ of the commonality of passing
> NULL through varargs functions.
I forgot to cite my reference:
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stddef.h.html#ta...
"NULL
Null pointer constant. [CX] [Option Start] The macro shall expand
to an integer constant expression with the value 0 cast to type void *.
[Option End]"
...
"RATIONALE
The ISO C standard does not require the NULL macro to include the
cast to type void * and specifies that the NULL macro be
implementation-defined. POSIX.1-2008 requires the cast and therefore
need not be implementation-defined."
where the CX option represents requirements that POSIX makes
above-and-beyond bare C99.