target is x86_64-apple-darwin15.4.0 (Apple LLVM 7.3.0)
This function
===== vec.c =====
#include <stdlib.h>
int vec(int index)
{
return ((int*) NULL)[index];
}
target is x86_64-apple-darwin15.4.0 (Apple LLVM 7.3.0)
This function
===== vec.c =====
#include <stdlib.h>
int vec(int index)
{
return ((int*) NULL)[index];
}
Short answer: No, unfortunately.
Longer answer: The runtime failure should help you catch these. Clang does have a diagnostic for /really/ obvious cases of null dereference:
null.c:3:3: warning: indirection of non-volatile null pointer will be deleted, not trap [-Wnull-dereference]
*((int*)NULL) = 3;
^~~~~~~~~~~~~
But that doesn't seem to cover array deref - you could file a bug/provide a patch to enhance that warning to cover the array deref case.