C++ Optimizer Bug

Hello, the following code behaves different in debug and release mode. The debug output is correct while in release mode it seems that there is no integer overflow and instead the value is calculated with a 64 bit value.

@ Apple: can you confirm it?

#include <iostream>
#include <string>

//------------------------------------------------------------------------
int main ()
{
	signed long long checkSum {14120563136728876};
	int i = 23342251;
	std::string theString {"\\"};

	// one ch is working, one is not
	// compare by using the first one or the second one

//	unsigned char ch {0b01011100}; // 92
	unsigned char ch = theString[0]; // 92

	checkSum += (int)ch * (i + 1); // different result in Debug and Release Mode

	std::cout << checkSum << "\n";

	return 0;
}
C++ Optimizer Bug
 
 
Q