▲ | wpollock 4 days ago | |
> But... we humans can easily conclude this is safe. After the evaluation of list_ref_a.push(5), my_list is still there, and it's still in a valid state. So there is no risk of memory errors when evaluating the second call to push. Is the always true? What with piplining, branch prediction, and maybe asymmetrical NUMA , isn't out of order instructions possible? If so, don't you still need locks or memory barriers to ensure safety? (I am most definitely not an expert, just curious.) | ||
▲ | nmsmith 4 days ago | parent [-] | |
Hardware-based instruction reordering always preserves the behaviour of the original program. (Assuming the original program is valid.) For example, an Intel CPU won't reorder `x += 1` and `x *= 2`. |