Code:
#include <stdio.h>
static void (*ptr)(void) = NULL;
void f(void) { puts( "hello" ); }
void g(void) { ptr = f; }
int main( void ) { ptr(); }
In clang, strange as it seems, this code will print "hello" (but g() is never called, how is this possible?).
Ok... derreferencing a NULL pointer is a UB... but every other compiler gives us an 'segmentation fault' or 'access violation'. Why clang initializes ptr with f, instead of the explicit (void *)0?
Take 'static' off and the code behaves as expected.