内存地址0x0是否可用? [英] Is memory address 0x0 usable?

查看:818
本文介绍了内存地址0x0是否可用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道...如果当你做一个新的,预订开始的地址是0x0?我想这是不可能的,但为什么?
是为此而准备的新操作符?是第一个字节的一部分不可用?它始终保留在操作系统启动时?

I was wondering... what if when you do a new, the address where the reservation starts is 0x0? I guess it is not possible, but why? is the new operator prepared for that? is that part of the first byte not usable? it is always reserved when the OS starts?

谢谢!

推荐答案

空指针不一定是地址 0x0 ,因此架构可以选择另一个地址来表示您可以从 new 中获取 0x0 作为有效地址。 (我不认为任何人都这样做,btw,它会破坏逻辑背后吨的 memset 调用,它只是更难以实现)。

The null pointer is not necessarily address 0x0, so potentially an architecture could choose another address to represent the null pointer and you could get 0x0 from new as a valid address. (I don't think anyone does that, btw, it would break the logic behind tons of memset calls and its just harder to implement anyway).

是否由操作系统 C ++实现 code> new 永远不会返回一个空指针,不管它的地址是什么( nothrow new 是一个不同的野兽)。因此,要回答您的问题:

Whether the null pointer is reserved by the Operative System or the C++ implementation is unspecified, but plain new will never return a null pointer, whatever its address is (nothrow new is a different beast). So, to answer your question:


内存地址0x0是否可用?

Is memory address 0x0 usable?

也许,这取决于具体的实现/架构。

Maybe, it depends on the particular implementation/architecture.

这篇关于内存地址0x0是否可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆