Re:Git Security Vulnerabilities Announced
by comex on Tuesday January 17, 2023 @04:34PM
(#34419590)
Part of it is that most CPU architectures don’t make overflow checking as cheap as it could be (there’s no option to trap on overflow, so you need a branch after every arithmetic operation, which has some cost). Another part is the compiler: a lot of compiler optimizations assume that arithmetic is a pure operation that can be added and removed and reordered as needed. So right now, adding overflow checks means opting out of a ton of optimizations. With care it may be possible to recover most of those optimizations, but it would require major improvements to LLVM.
[ Parent
| on HN ]
Re:Git Security Vulnerabilities Announced
by superjan on Tuesday January 17, 2023 @05:20PM
(#34420278)
This is a great point. But how about if the language would allow the programmer to specify what range of values is expected for function input/output?
Then a compiler could try to reason about the computation and decide that overflow does not happen if all values are within bounds, and just add checks at the function boundaries.