小编zse*_*zse的帖子

在空指针中存储整数的往返安全

本文中,提到了有关reinterpret_cast整数和指针的以下内容:

(不保证相反方向的往返转换;同一个指针可能有多个整数表示)

我是否正确理解标准不保证以下内容:

intptr_t x = 5; 
void* y = reinterpret_cast<void*>(x);
assert(x == reinterpret_cast<intptr_t>(y));
Run Code Online (Sandbox Code Playgroud)

有人可以确认吗?

c++ pointers language-lawyer reinterpret-cast

4
推荐指数
1
解决办法
328
查看次数

标签 统计

c++ ×1

language-lawyer ×1

pointers ×1

reinterpret-cast ×1