Thanks to the wonders of UB, the sample on the article when compiled with optimization on, it actually reduces to,<p><pre><code> //clang -o null_dereference null_dereference.c
#include <stdio.h>
int main() {
int *ptr = NULL; // Initialize a pointer to NULL
int value = *ptr; // Attempt to dereference the NULL pointer
printf("Value: %d\n", value); // This line will reached, because the previous will be optimized away.
return 0;
}
</code></pre>
Example, <a href="https://godbolt.org/z/Kv3rcz1ch" rel="nofollow">https://godbolt.org/z/Kv3rcz1ch</a>