内存地址0x0是否可用?

编程入门 行业动态 更新时间:2024-10-28 22:34:15
本文介绍了内存地址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是否可用?

本文发布于:2023-07-27 15:59:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1223273.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内存   地址

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!