Reputation: 34810
Possible Duplicate:
Best way to detect integer overflow in C/C++
I'm writing code where I may run into a situation where an overflow may occur as a multiplication of two integers. As far as I tested, no exception is thrown anywhere.
I am using Visual Studio 2010 and I've looked at the C++ compiler options to check overflow but there's nothing about it. I have all the optimizations off, but still not getting an error while performing multiplication (which DOES result in overflow). I can't change some critical parts of my code, and I need a way to detect overflow, I know hardware will raise an exception in the case of an exception, but couln't get it working.
Upvotes: 4
Views: 140