On 02/20/2015 10:30 AM, Andrew Haley wrote: > I doubt that such a thing is ever going to be safe. The idea that a > null pointer points to nothing is so hard-baked into the design of C > that you can't get away from it. Also, almost every C programmer and > especially library writer "knows" that a null pointer points to > nothing.
NULL pointer dereferences (or NULL pointer with small offsets) were common programming idioms in the DOS days because the interrupt vector table was located at this address. Quite a few systems once had a readable page zero, and (manual, I assume) optimizations for list traversal (p != NULL && p->next != NULL → p->next != NULL) were commonly used on these systems. I think the treatment of pointers not as addresses, but something that has type information and provenience associated with it, came much later, when most of the design was already settled. -- Florian Weimer / Red Hat Product Security