3 ms·
> a type system only deserves that name if it prevents use-after-free errors Or another way to look at it: if I tell you you're holding an Integer, and when yo
by mrkeen 3y ago
> a type system only deserves that name if it prevents use-after-free errors
Or another way to look at it: if I tell you you're holding an Integer, and when you try to use it in addition, it explodes, was I really justified in telling you you were holding an Integer?
- rwmj 3y agoThat's kind of a bad example because adding integers can overflow (in some languages).
- shadowgovt 3y agoDepending on how you turn your head and squint, overflow is still well-defined: if I add a to b and it overflows to c, it still overflows to the same c every time. That means addition is sound in that architecture, it just has surprising consequences and some properties one would expect naively to hold for positive-integer arithmetic don't hold for the computer addition operation (such as c > a && c > b for all a > 0 and b > 0).
- staunton 3y agoC/C++ (the standard) makes no claims about what happens if you overflow integers. The program might set all your variables in the whole program to zero if it likes. Of course the compiler vendors wouldn't do that but they're allowed to. That's what "undefined" means at least in C/C++.
- Kamq 3y ago> C/C++ (the standard) makes no claims about what happens if you overflow integers. It makes no claims on what happens when you overflow signed integers. Unsigned integer wrapping is specified by section 6.2.5, paragraph 9 of the C standard.