Please consider the following code:int _tmain(int argc, _TCHAR* argv[]){ char c = 0xC3; char* pc = &c; unsigned short s = *pc; if(s > 0xFF) cout << "A" << endl; else cout << "B" << endl; return 0;}When compiled in VS 2010 SP1 in 32bit, this code does not produce the same result in debug and release mode: In debug "A" is displayed, in release "B" is displayed.Now if I display s at the end of the function like this:int _tmain(int argc, _TCHAR* argv[]){ char c = 0xC3; char* pc = &c; unsigned short s = *pc; if(s > 0xFF) cout << "A" << endl; else cout << "B" << endl; cout << s << endl; return 0;}The behaviour in release mode is changed and "A" is displayed.It this a bug of the optimiser?Ben
Visual Studio/Team Foundation Server/.NET Framework Tooling version
Steps to reproduce
Product Language
Operating System
Operating System Language
Actual results
Expected results
Please wait...