Possible duplicate:
Best way to detect integer overflow in C / C ++
I am writing code where I may encounter a situation where overflow can occur as a multiplication of two integers. As far as I tested, an exception is not thrown anywhere.
I am using Visual Studio 2010, and I looked at the C ++ compiler options to check for overflow, but there was nothing about it. All optimizations are disabled for me, but I still don’t get an error while doing the multiplication (which leads to overflow). I cannot change some critical parts of my code, and I need a way to detect overflow, I know that the hardware will throw an exception in case of an exception, but it cannot make it work.
source share