3 ms·
One doesn't need to use complex template techniques, a class like CSafeInt should cover all integer overflow bugs with run-time checks. The problem is that alm
by blub 10y ago
One doesn't need to use complex template techniques, a class like CSafeInt should cover all integer overflow bugs with run-time checks.
The problem is that almost no one is thinking about this class of bugs. Furthermore, few languages offer tools to detect and handle integer overflows; I read that Rust for example only has run-time checks in the debug version, which to me is disappointing.
- kouteiheika 10y ago> I read that Rust for example only has run-time checks in the debug version, which to me is disappointing. Only by default; you can turn them on in release builds too if you want. (And Rust 1.17 will have a stable `-C overflow-checks=y` flag which allows you to turn on the overflow checks without other debug assertions.)
- lmm 10y ago> a class like CSafeInt should cover all integer overflow bugs with run-time checks If that's all you want it's easy to do that in any language? What's so special about C++? The reason this gets talked about more in C++ is that the consequences of integer overflow in C++ are dreadful (undefined behaviour i.e. instant security bug) whereas in most languages adding two integers will evaluate to an integer.