Re:Integer Overflow Bug in Boeing 787 Dreamliner
by smsm42 on Saturday May 02, 2015 @05:55PM
(#9478722)
I'm not sure how C is specifically to blame for something like int overflow - while in many languages this specific problem won't happen, in many popular ones it would happen the same way as in C. E.g. doesn't Rust also have limited integer types?
[ Parent
| on HN ]
Re:Integer Overflow Bug in Boeing 787 Dreamliner
by steveklabnik on Saturday May 02, 2015 @06:26PM
(#9478807)
In Rust, integer overflow is defined behavior, though: https://github.com/rust-lang/rfcs/blob/master/text/0560-inte...
Re:Integer Overflow Bug in Boeing 787 Dreamliner
by smsm42 on Saturday May 02, 2015 @07:08PM
(#9478910)
True, but as far as I see from this RFC, you have to explicitly check for overflow or run code in debug mode (which of course doesn't help unless your CI includes the one-year-without-reboot test, which would probably do wonders to the production schedules ;). If you thought about it, when writing that code, then you could add the same check in C too! The whole issue is that most people do not make such checks consistently.
Re:Integer Overflow Bug in Boeing 787 Dreamliner
by randomsearch on Saturday May 02, 2015 @07:49PM
(#9479034)
> I'm not sure how C is specifically to blame for something like int overflow
C is not a good choice when safety is paramount.
"The low-level nature of C and C++ means that bit- and byte-level manipulation of objects is commonplace; the line between mathematical and bit-level operations can often be quite blurry. Wraparound behavior using unsigned integers is legal and well-defined, and there are code idioms that deliberately use it. On the other hand, C and C++ have undefined semantics for signed overflow and shift past bitwidth: operations that are perfectly well-defined in other languages such as Java."