Is it safe to assume sizeof(double) >= sizeof(void*)?

狂风中的少年 提交于 2019-12-06 14:50:49

On current systems yes. double is 64 bits on all current and future systems because they're aligned with IEEE arithmetic's double-precision. It's unlikely but certainly possible that pointers could be larger in the future - probably not for the sake of larger address space, but instead for carrying with them bounding information.

In any case it seems like a really bad idea to rely on any relationship between double and void *...

The size has nothing to do with it. There will always be some bits stored in there and the size will always be large enough to hold a void*. What will go wrong is that you interpret an almost random bit pattern as a pointer, this can't do much else than crash, but most probably you knew that already. Don't do it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!