It would be nice to see something like that standardised so you could use it in portable code.
It doesn't solve the problem though. You still need to write some code for what to do if there's an overflow, and you need separate handling for underflow. So the signed case is now:
Work in progress. I've given up on figuring out what arguments to pass to g2 and g3. Since the difference won't fit in an int, you would need to offset-adjust the value somehow in order to fit it in an int. Seems messy. Maybe you can think of something simpler.
https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins...