[MPlayer-dev-eng] [PATCH] cast null pointers
Christopher Key
cjk32 at cam.ac.uk
Thu Aug 12 19:23:11 CEST 2010
Reimar Döffinger wrote:
> On Thu, Aug 12, 2010 at 06:54:35PM +0200, Reimar Döffinger wrote:
>
>> On Thu, Aug 12, 2010 at 04:56:49PM +0100, Edd Barrett wrote:
>>
>>> Just a small stylistic note. Null pointers for execl should be casted to
>>> pointer types. Pointed out to me by naddy@ (http://c-faq.com/null/null2.html):
>>>
>> What a nonsense, the C99 standard (e.g. section 7.17) specifies NULL
>> as a "null pointer constant", so it is required to be a pointer type.
>> Some implementations may not conform to this, but unless you know
>> of a specific one where this actually causes issues this is just
>> obfuscation.
>>
>
> Hm, I managed to get myself confused by the language.
> A "null pointer constant" is actually not required to be a "null
> pointer" and thus to be of pointer type.
> Seems somewhat silly to me, but well.
>
There's no guarantee that the various pointer types are interchangeable,
only that void* be large enough to represent any data pointer. In
pointer context, 0 will always work. In a non pointer context, there's
no guarantee that ((void *) 0) will do the correct thing, hence the
requirement for an explicit cast.
I read [1] recently, and it explained this rather better than I can.
Kind regards,
Christopher Key
[1] http://c-faq.com/~scs/cgi-bin/faqcat.cgi?sec=null
More information about the MPlayer-dev-eng
mailing list