Detecting integer overflow in C and C++