如何表示指向我的地址空间开头的指针? [英] How do I represent a pointer to the beginning of my address space?
问题描述
在一些罕见的旧机器上,整个具有不同于0的特殊值的NULL指针是可能的,但实际上,指向地址0的NULL / 0指针将具有值0,并且在大多数机器上真正指向地址0 。
这将是完全可解除引用的,如果有一些内存映射到这个区域,你可以在该地址上写。
我曾经在一个嵌入式平台上工作过。所以我习惯在地址0上放置一个调试器观察点,因为对这个区域的所有访问都是NULL指针解引用。以这种方式捕获一些错误^^
Let's consider some strange hypothetical embedded system where I need to produce and use a pointer that points to, or might point to, the first byte of my address space. That is, a pointer equal to zero. Not a NULL pointer, but a perfectly valid zero pointer, which might get dereferenced or incremented or treated as an array just like any other pointer. How would I do this in languages that treat a NULL pointer as special, but don't have a real NULL type?
The whole "NULL pointer having a special value different than 0 treated special" is a possibility on some rare old machines, but in practice, your NULL/0 pointer pointing to adress 0 will have value 0 and really point to address 0 on most machines.
It will be perfectly dereferenceable, and you can write on that address if there is some memory mapped to this area.
I used to have that on an embedded platform I worked with. So I used to put a debugger watchpoint on address 0, since all accesses to this area were NULL-pointers dereferences. Caught some errors that way ^^
这篇关于如何表示指向我的地址空间开头的指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!