The nullptr and pointer arithmetic

前端 未结 4 586
执念已碎
执念已碎 2021-02-05 21:23

Considering the following code, is it safe to do pointer arithmetic on nullptr?

I assume adding any offsets to a nullptr results in another

4条回答
  •  不知归路
    2021-02-05 22:11

    No, adding an offset to a nullptr does not result in a nullptr. This is undefined behavior.

提交回复
热议问题