4 ms·
The compiler cannot assume that much, because the argument is a signed integer (negative integers will not overflow and do have well-defined behaviour).
by eMSF 5y ago
The compiler cannot assume that much, because the argument is a signed integer (negative integers will not overflow and do have well-defined behaviour).
- davemp 5y agoThe rabbit hole goes deeper than that: https://gcc.godbolt.org/z/Tc1MTa6nj https://gcc.godbolt.org/z/Tc1MTa6nj
- rocqua 5y agoThat is a well defined function. And indeed implements isEven. Because unsigned int has defined overflow semantics. Essentially, it will eventually overflow and hit the correct base-case for 0.