I know there’s an old saying when you want to indicate this specific pointer doesn’t point to anything it should be set to NULL(actually 0), but I’m wondering isn’t there actually a physical part of memory with the address of NULL(0) ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is always a physical address of 0 (but it may not necessarily map onto physical RAM), but on a typical platform any accesses will typically be performed in a virtual address space (as jweyrich points out below, you can use
mmapand so on to directly map the physical address space), so any attempt to read/write to address 0 will raise an exception of some kind.On simpler processors (think microcontrollers and so on), there may be no such protection, so if you attempt to write to address 0, there’ll be nothing to catch you.
Note also that a null pointer doesn’t necessarily have to point at address 0; the only guarantee is that it will compare equal to integer value
0.