Re:Dereferencing NULL Pointer, without a Seg Fault
by DannyBee on Wednesday July 11, 2012 @12:54AM
(#4227787)
Fun fact: There are a number of platforms that made NULL dereference valid (usually returning zero), because it enables you to do fun compiler optimizations that are not safe otherwise. Some of these optimizations relate to being able to insert new loads or hoist existing ones, some of these relate to being able to remove null pointer checks.
(for example, in:
int **a = NULL;
int *b = NULL;
int c = 0;
...
if (a ! = NULL)
b = *a;
if (b != NULL)
c = *b;
you can remove all the NULL checks if *NULL = 0)
AIX was an example of such a platform (at least until version 5.3, i haven't used it since then).
AIX was an example of such a platform (at least until version 5.3, i haven't used it since then).