Are most compilers able to check if an addition operation that was performed earlier in the code resulted in a carry?
For example:
unsigned int n = 0xFFFFFFFF; // 8 F's
// doing some stuff here ...
n = n + 1;
// doing some stuff here, without changing the value of @var n
if (n > UINT_MAX) {
// n has a carry
}
Unsigned ints will wrap around to 0 in your example (assuming your c implementation uses 32 bit unsigned ints). The compiler can’t tell if they wrap around, you need to check your result to see.