3 ms·
Why? This sort of optimization is necessary in order to make programs run fast.
by umanwizard 9y ago
Why? This sort of optimization is necessary in order to make programs run fast.
- megous 9y agoWhat kind of optimization? I'd rather this kind of code would crash on me, like the code that gcc compiles out of this, rather than compiler silently doing crazy inferences out of obviously buggy code.
- umanwizard 9y agoFor this particular edge case, yes it seems absurd. However, many optimization passes are based on simplifying code by figuring out what range of values something can take. Most optimization passes don't know what the original code looks like, they only see it after it's been passed through a bunch of other optimization passes and preprocessing, so they can't reason about whether a particular optimization would seem "completely natural" or "abuse of UB" to the original programmer.