4 ms·
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
by zajio1am 5y ago
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.
- WalterBright 5y ago> as in most cases it is not expected behavior Yeah, but the gotcha happens when it is expected behavior.
- nwmcsween 5y ago-fsanitize-undefined-trap-on-error