3 ms·
There are several ways to do overflow checks safely (i.e. without undefined behavior), though the ergonomics are not always ideal. C23 somewhat improves the si
by comex 4y ago
There are several ways to do overflow checks safely (i.e. without undefined behavior), though the ergonomics are not always ideal.
C23 somewhat improves the situation with <stdckdint.h>, a standardized version of GCC’s __builtin_add_overflow and friends. That has ergonomics issues too due to its verbosity, but at least it’s hard to screw up.