Well, as you know, the physical representation of null pointer of a given type is not necessarily all-zero bit pattern. When you forcefully convert a pointer (any pointer) value to integer type, the result is implementation defined, but normally (and that's the intent) the numerical value of the pointer - the numerical address - remains unchanged, if possible. This means that if on a given platform a null pointer of type char *
is represented by 0xBAADF00D
pattern (for example), the above expression will evaluate to 0xBAADF00D
, and not to zero. Of course, for that you'd need a platform with non-zero null-pointers. I personally never worked with such platforms, although I heard about a number of real platforms like that out there (like, in the realm of embedded platforms it is not something unusual).
Moreover, as an additional note, null pointer values of different types can have different physical representations, meaning that in theory you can get different values from (size_t) ((int *) 0)
, (size_t) ((char *) 0)
and (size_t) ((double *) 0)
. But that would be a rather exotic situation, albeit perfectly possible from the point of view of abstract C language.
P.S. Read here (C FAQ) for some examples of actual platforms with non-zero null pointers.