3 ms·
Try something like this with optimization on: int would_increment_overflow(int a) { if (a + 1 < a) { return -1; return 0; } This get
by dezgeg 3y ago
Try something like this with optimization on:
int would_increment_overflow(int a) {
if (a + 1 < a) {
return -1;
return 0;
}
This gets turned to a function that always returns 0.
0000000000000000 <would_increment_overflow>:
0: f3 0f 1e fa endbr64
4: 31 c0 xor %eax,%eax
6: c3 retq
Using unsigned int gives the wrapping semantics.