Ben Bacarisse <> writes:
> pete <> writes:
>> Stephen Sprunk wrote:
>>> Malcolm McLean wrote:
[...]
>>>> Surely there is some rule that NULL can be used as the null pointer
>>>> constnant, in all contexts?
>>>
>>> Nope. NULL is allowed to be defined as 0, in which case it only
>>> becomes a null pointer constant when converted to a pointer; in
>>> other contexts, it's simply an integer.
>>
>> 0 is a null pointer constant. That's all, no context.
>>
>> 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.
>
> It is also an integer constant or 6.3.2.3 would not apply. It is
> clearly both at the same time so why do you seem to be suggesting that
> context does not matter?
Yes, 0 is both an integer constant and a null pointer constant. I
think pete's point (which I agree with) is that 0 is a null pointer
constant (or at least is "called" a null pointer constant) regardless
of the context in which it appears. The 0 in:
int x = 0;
is by definition a null pointer constant, even though it's not
converted to a pointer type.
--
Keith Thompson (The_Other_Keith)
<http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"