I\'m writing C code for a system where address 0x0000 is valid and contains port I/O. Therefore, any possible bugs that access a NULL pointer will remain undetected and at t
The standard states that an integer constant expression with value 0, or such an expression converted to the void *
type, is a null pointer constant. This means that (void *)0
is always a null pointer, but given int i = 0;
, (void *)i
need not be.
The C implementation consists of the compiler together with its headers. If you modify the headers to redefine NULL
, but don't modify the compiler to fix static initialisations, then you have created a non-conforming implementation. It is the entire implementation taken together that has incorrect behaviour, and if you broke it, you really have no-one else to blame ;)
You must fix more than just static initialisations, of course - given a pointer p
, if (p)
is equivalent to if (p != NULL)
, due to the above rule.