Why would it be UB? All objects are behind (thin) pointers, which can be overwritten atomically.
void foo(int *a, int b) { a[b] = 1}
At runtime there is no information about whether that write is in bounds and no way to prevent this from corrupting arbitrary data unless you compile for something like CHERI.