Does Standard define null pointer constant to have all bits set to zero?

前端 未结 4 759
北恋
北恋 2020-12-07 05:27

( I\'m quoting ISO/IEC 9899:201x )

Here we see that, integer constant expression has an integer type:

6.6 Constant expressions

6. An in

4条回答
  •  無奈伤痛
    2020-12-07 05:35

    Asking about the representation of a null pointer constant is quite pointless.

    A null pointer constant either has an integer type or the type void*. Whatever it is, it is a value. It is not an object. Values don't have a representation, only objects have. We can only talk about representations by taking the address of an object, casting it to char* or unsigned char*, and looking at the bytes. We can't do that with a null pointer constant. As soon as it is assigned to an object, it's not a null pointer constant anymore.

提交回复
热议问题