4 ms·
You may be interested in http://blog.regehr.org/archives/1139 http://blog.regehr.org/archives/1139 by the same author, and also the (GNU) compiler built-ins for
by dbaupp 11y ago
You may be interested in http://blog.regehr.org/archives/1139 http://blog.regehr.org/archives/1139 by the same author, and also the (GNU) compiler built-ins for exactly that task https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins... .
(Note that your second example can't work in C/C++, since the check happens after the operation.)
- daurnimator 11y ago> (Note that your second example can't work in C/C++, since the check happens after the operation.) I think the poster already knew that, hence the `magic`.