Why would it be UB? All objects are behind (thin) pointers, which can be overwritten atomically.