|
|
|
|
|
by Dylan16807
687 days ago
|
|
> What should the compiler emit here? It should emit an instruction to access memory location some_array + i. That's all most people that complain about optimizations on undefined behavior want. Sometimes there are questions that are hard to answer, but in a situation like this, the answer is "Try it and hope it doesn't corrupt memory." The behavior that's not wanted is for the compiler to wildly change behavior on purpose when something is undefined. For example, the compiler could optimize if(foo) {
misbehaving_code();
return puppies;
} else {
delete_data();
}
into delete_data();
|
|