How to detect integer overflow in C [duplicate]
问题 This question already has answers here : Detecting signed overflow in C/C++ (12 answers) How do I detect unsigned integer multiply overflow? (31 answers) Closed 9 months ago . We know CPython promotes integers to long integers (which allow arbitrary-precision arithmetic) silently when the number gets bigger. How can we detect overflow of int and long long in pure C? 回答1: You can predict signed int overflow but attempting to detect it after the summation is too late. You have to test for