I don't remember what UBSan looked like in 2014, but it does something not entirely unhelpful for each of these examples, although they are caught at run time, not compile time:
runtime error: index 4 out of bounds for type 'int [4]'
UndefinedBehaviorSanitizer: SEGV on unknown addres
runtime error: reference binding to null pointer of type 'int'