2 ms·
Yes exactly the requirement that program is "well formed" is what leads to optimization opportunities. Not its "ill formedness". Nobody writes optimizations thi
by ensiferum 6y ago
Yes exactly the requirement that program is "well formed" is what leads to optimization opportunities. Not its "ill formedness". Nobody writes optimizations thinking "this program is ill formed I can enable this and that optimization" but exactly the reverse. "This program is well formed so I can enable some optimization."
- est31 6y agoI think we are talking past each other. When I said "undefined behaviour" above, I meant the concept of it. The fact that the language spec has undefined behaviour is what enables the compiler to make assumptions. The language spec could for example say that out of bounds indexing in an array is defined behaviour, and defined to raise a trap. But implementing that would slow down a lot of code. You refer to the ill formed code itself that violates the language specification. That's not what I meant. Yes, the fact that this code becomes garbage is a side effect of the optimizer's assumption that code is always well formed, instead of some arcane idea of punishing people who don't follow an arbitrary specification. I think we both agree.