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

The article mentions cases where integer overflow is expected behavior.



C already offers 'unsigned' type variants that offers defined overflow (together with non-negative range).

It would be useful to have another type variant that offers defined overflow (like in unsigned) together with signed range for such cases. But it still makes sense for basic integers to have overflow as UD, as in most cases it is not expected behavior.

Note that in current C, if one needs defined overflow on signed integers, one can cast them to unsigned, to the operation and cast result back to int. That makes it implementation-defined instead of undefined.


> as in most cases it is not expected behavior

Yeah, but the gotcha happens when it is expected behavior.


-fsanitize-undefined-trap-on-error




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: