Visual Studio C++ 2015 Compiler Bug

I think I’ve unfortunately found a compiler bug in Visual Studio 2015, all the way back to at least VS2010. Here is the code:

Compile and run in 64bit, Release. This is the expected output (as with g++, clang++, or in debug):

This is what I get with 64bit, Release:

Also see my stackoverflow post. The compiler seems to optimize too much, and directly uses a 64bit number instead of making sure the 32bit value is casted to 64bit. I have already reported the bug to Microsoft, and wait for feedback.

Be the First to Comment!

Notify of