com.lang.c FAQ answers question 5.16 , which explains why this happens, and question 5.17 , which gives examples of real machines with non-zero NULL . A relatively βgeneralβ case is suitable for address 0, so another invalid address is selected for NULL . A more esoteric example is the Symbolics Lisp Machine, which does not even have pointers as we know them.
So itβs not a matter of choosing the right compiler. In a modern byte-addressable system with or without virtual memory, you are unlikely to encounter a NULL pointer, which is not address 0.
Standard C has been carefully designed to host hardware that is completely strange, and this is just one result. Another weird loot on the same lines is that it is possible for sizeof(void *) != sizeof(int *) , but you will never see that this happens in an architecture with a byte address.
Dietrich epp
source share