Re:Calloc or Malloc? Any thoughts?
by yan on Wednesday August 13, 2008 @12:58PM
(#275145)
I'm just curious, but can you point me to an implementation of C that doesn't treat (void*)0 as NULL?
[ Parent
| on HN ]
( void* )0 is NULL, in that NULL is (most usually) #defined to be ( void* )0. But the literal 0 in a pointer context doesn't guarentee that the null pointer is actually all bits zero.
To put it another way, if you have a literal zero in a pointer context, the compiler will replace it with the machine's representation of a null pointer, which may or may not be a machine word with all bits zero.
I think that's right...
You are theoretically correct.
But: can you name a platform where a null pointer is not represented by zeros in binary?
See section 1.14
http://www.lysator.liu.se/c/c-faq/c-1.html