|
|
if (ptr == 0)
. I can also write a function that returns a pointer, and I can return 0 to signify there's nothing to return, and the caller of my function would do the same exact comparison. So how come this cannot be guaranteed to be a null pointer?
After all, I am comparing the pointer there to a value. |
|
|
the standard wrote: |
---|
A value of integral type or enumeration type can be explicitly converted to a pointer.64) A pointer converted to an integer of sufficient size (if any such exists on the implementation) and back to the same pointer type will have its original value; mappings between pointers and integers are otherwise implementation-defined. ... 64)Converting an integral constant expression with value zero always yields a null pointer, but converting other expressions that happen to have value zero need not yield a null pointer. page 75 |