In C / C ++, it is not allowed to access data at address 0.
However, the physical memory is numbered from 0. And in the DOS era, the interrupt vector table was at physical address 0. The first interrupt vector was an exception handler of zero.
My question is:
When is access to physical address 0 allowed?
To access the physical address zero, it depends on which platform you are talking to. The language has no idea about the basic addressing model; it depends on the OS.
mmap
PS. , , .
C/++ 0.
, , . .
0?
, . - , , , . .
, .
C ( ++), , (void*)0 . undefined .
(void*)0
C ++ NULL ( ++ 11 nullptr ).
nullptr
C ( , ) , . GCC .
C ++ , , ( , libc). , , , NULL ( ).
C, NULL -, . .
NULL
, . mmap (2) POSIX Linux.
, 0 C, .
C ++ , . , , " 0", " 0 ", . C/++.
: -
uintptr_t null_address = 0; void *ptr = (void *) null_address;
C , , . (0 w980 > *) 0x1234 0x1234, C .
C , - , . , , .
, , . , , . , .
. , " ". . .
. , .
. , .
, , , ( ).