26 Nov
2018
26 Nov
'18
10:57 p.m.
On 27/11/2018 11:29, Steven Watanabe wrote:
signed integer overflow has undefined behavior. unsigned integers wrap. This means that signed integers give the compiler more scope for optimization and/or runtime checks.
I'm not aware of any compilers that actually do that, even in debug mode. (Apart from ubsan, of course, but that also checks for unsigned "overflow".) Avoiding possible undefined behaviour sounds like a good reason to avoid signed integers in general. (Except where actually required.) (Not that unintended wrapping of unsigned integers is much better, but at least it's less likely to summon Nyarlathotep.)