That’s true. You have to understand that abstract machine, what it guarantees, and how that relates to your hardware and what it guarantees.
I really need to finish my own blog post series on this topic...
I really need to finish my own blog post series on this topic...
The compiler does not enforce it though. It only implements the abstract machine, and the implementation is only correct for UB-free programs.
The actual hardware behavior is useful for other purposes, like understanding why the abstract machine is the way it is, or understanding and improving the performance of well-defined programs, but it is not useful at all once you have UB.