[fpc-pascal] NULL pointer to array of integer

Vinzent Höfler JeLlyFish.software at gmx.net
Wed Sep 13 20:33:07 CEST 2006

Jonas Maebe wrote:
> On 13 Sep 2006, at 19:39, Vinzent Höfler wrote:
>>>  In FPC, nil = pointer(0) on all currently supported platforms, but in
>>>  principle it could be anything.
>> I'm making enemies now,
> Where?
>> but:
>> If the NIL pointer is represented by another value (like 0xFFFFF780 or 
>> such) on a given target platform, the integer conversion from a 
>> _compile-time_ constant 0 literal should still lead to a NIL 
>> representation.
> I don't see why, except for compatibility with code built on wrong 
> assumptions.

For C language interfacing, I'd say.

>> Basically that would be the same behaviour as what the C-standard 
>> guarantees.
> Does it guarantee that (void*)(0) == NULL?

Yes. It's about the only guarantee it gives regarding the "null pointer 

--- 8< ---

ISO/IEC 9899:1999 (E) - Pointers

3 An integer constant expression with the value 0, or such an expression 
cast to type void *, is called a null pointer constant[55] 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.
4 Conversion of a null pointer to another pointer type yields a null 
pointer of that type.
Any two null pointers shall compare equal.
5 An integer may be converted to any pointer type. Except as previously 
specified, the result is implementation-defined, might not be correctly 
aligned, might not point to an entity of the referenced type, and might 
be a trap representation.

[55] The macro NULL is defined in <stddef.h> (and other headers) as a 
null pointer constant; see 7.17.

--- 8< ---


More information about the fpc-pascal mailing list