2 ms·
But "unsigned" doesn't actually enforce the semantics you want. Missing an overflow check means your value will never be negative, but it is almost certainly st
by UncleMeat 6y ago
But "unsigned" doesn't actually enforce the semantics you want. Missing an overflow check means your value will never be negative, but it is almost certainly still a bug. And because unsigned overflow is defined, the compiler isn't allowed to prevent you from doing it!
This is just enough type semantics to injure oneself.
- dkersten 6y agoSo, because its not perfect, should you throw it all out?
- UncleMeat 6y agoNo. Because people tend to make more mistakes if they try to use unsigned values in this manner in C/C++.
- dkersten 6y agoI’ve personally never encountered a bug that turned out to be caused by an unsigned value. YMMV, I guess.
- UncleMeat 6y agoIf seen all sorts of bugs caused by surprise conversions, as well as overflows that cause bugs that would be statically detectable but can't become blocking errors because unsigned overflow is well defined.