The only "handling" that the compiler does, is that 0
is not necessarily translated as the address memory 0
. This is implementation specified.
The compiler will simply map this 0
to a specific address that cannot possibly be part of the process user space.
When trying to access an address outside of the process user space, the OS will typically "catch" the access and issue and error. On Unix systems, this is the infamous SEGFAULT.
Note that this very same error is also emitted for a pointer with a garbage value that points outside the process user space.