[LLVMdev] Call to address 0 gets removed

me22 me22.ca at gmail.com
Tue Jun 9 19:28:37 PDT 2009


2009/6/9 Dale Johannesen <dalej at apple.com>:
>
>>
>> Although a C translation unit may arguably not assign a
>> correspondingly
>> defined function as having a pointer value (address) comparing equal
>> to
>> ((void *) 0);
>
> Nothing arguable about it, see C99 6.3.2.3
>
>> it's not clear that the standard forbids the invocation of  such a
>> function
>
> No such function can exist.  I don't think the standard forbids you to
> call 0, but it makes calling 0 undefined behavior ("behavior, upon use
> of a nonportable or erroneous program construct or of erroneous
> data"), since there can't possibly be a valid function there.
>

In C++, my understanding is that the null pointer --
static_cast<void*>(0) -- need not be the pointer whose representation
is all unset bits -- reinterpret_cast<void*>(0) -- and that only
loads/stores/calls/etc on the former are undefined behaviour, as there
may be architectures or programming levels on which referring to
memory address 0 is perfectly reasonable.

Does C99 have such a distinction as well?

~ Scott




More information about the llvm-dev mailing list