2 ms·
Alas, no. Signed overflow is UB and compilers can and will assume that it cannot happen when performing optimizations.
by mikeash 9y ago
Alas, no. Signed overflow is UB and compilers can and will assume that it cannot happen when performing optimizations.
- astrange 9y agoWhich is a good thing, assuming you did reasonable testing with ubsan etc. Having to assume things that never happen is a big problem for optimization!
- mikeash 9y agoThat's a good point. Seems like we could do a bit better than the current state of the art, though. If non-optimized builds trapped on overflow, that would at least give you a better chance of detecting these problems before the optimizer starts throwing out code you meant to keep.