CJ wrote:
But can't we get from the Standard the following two facts:
1) any pointer can be converted (possibly with loss of information) to
an int
There's something like that in the standard.
Either that, or the attempt can be undefined.
N869
6.3.2.3 Pointers
[#6] Any pointer type may be converted to an integer type.
Except as previously specified, the result is
implementation-defined. If the result cannot be represented
in the integer type, the behavior is undefined. The result
need not be in the range of values of any integer type.
2) the value of such a converted pointer
is 0 if and only if the pointer was NULL
No.
There's nothing like that in the standard.
N869
6.3.2.3 Pointers
[#3] An integer constant expression with the value 0, or
such an expression cast to type void *, is called a null
pointer constant. If a null pointer constant is
converted to a pointer type, the resulting pointer, called a
null pointer, is guaranteed to compare unequal to a pointer
to any object or function.