Is the pointer guaranteed to be > a certain value?

前端 未结 5 1424
猫巷女王i
猫巷女王i 2021-01-18 17:37

In C++ when i do new (or even malloc) is there any guarantee that the return address will be greater than a certain value? Because... in this project i find it

5条回答
  •  无人及你
    2021-01-18 17:52

    In theory, no -- a pointer's not even guaranteed to be > 0. However, in practice, viewed as an unsigned integer (don't forget that a pointer may have a high-order "1" bit), no system that I know of would have a pointer value less than about 1000. But relying on that is relying on "undefined behavior".

提交回复
热议问题