Hacker News new | past | comments | ask | show | jobs | submit login

if( x > INT_MAX - n ) // overflow for x + n

Your definition of a far more complicated dance is absurd.

Signed integer being undefined makes a lot of integer math faster actually: https://kristerw.blogspot.com/2016/02/how-undefined-signed-o...

There's a reason zig made unsigned overflow undefined: it allows for more optimisations (Zig can also afford it thanks to their wrapping addition (+%) operator).






Yes, thanks.

With C23 there are also now checked integers to do overflow checking for arithmetic operations.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: