Generally, the address space in virtual memory is managed by the operating system.
A freestanding C (or C++) implementation could certainly allow you to dereference (void*)0
in an implementation specific way. But beware of undefined behavior.
The C and C++ standards are very careful about the NULL pointer (and C++11 added the nullptr
keyword for several good reasons).
A C compiler (at least a hosted implementation) is allowed to suppose that after a successful dereference a pointer is not null. Some optimizations in GCC are doing that.
Most hosted C or C++ implementations have a null pointer which is an all-zero-bits word, but that is not required by the standard (however, it is very common; it helps the compiler and the libc).
However, pragmatically, a lot of software is supposing that NULL is represented by all-zero-bits (in theory it is a mistake).
I know no C implementation where NULL
is not all-zero-bits, but that is not required. However, coding such a compiler would be a headache.
On some operating systems, an application can change its address space, e.g. with mmap(2) on POSIX or Linux.
If you really wanted, you could access address 0 in C, but you really should never want to do that.