How disastrous is integer overflow in C++?
I was just wondering how disastrous integer overflow really is. Take the following example program: #include <iostream> int main() { int a = 46341; int b = a * a; std::cout << "hello world\n"; } Since a * a overflows on 32 bit platforms, and integer overflow triggers undefined behavior, do I have any guarantees at all that hello world will actually appear on my screen? I removed the "signed" part from my question based on the following standard quotes: (§5/5 C++03, §5/4 C++11) If during the evaluation of an expression, the result is not mathematically defined or not in the range of