On Tue, 1 Mar 2022 18:09:14 +0000, Seymour J Metz wrote:

>Is nullptr an address of 0, or is it an address guarantied to not be valid?
>
Ah, pedantry!  It depends on whether "invalid" is equivalent to "unequal
to a pointer to any object ..." (or whether one implies the other.). The
statement below does not constrain the storage representation of NULL
(as in type-punning).  I believe the behavior of "if ( NULL ) ..." (specified
elsewhere) requires that (intt) NULL be zero.

Cases to consider:
o a putative pointer to the interior of a multi-byte object
o an arbitrary int value cast to (void *)
o a pointer to a free()ed object.

>�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.�

-- 
gil

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to