I have stumbled upon a curious behavior in my program when compiling with Visual Studio 2013 Community, with the November 2013 CTP. The following program compiles and prints "true", while the expected behavior was that it'd print "false", which is what GCC and clang do.

I have tested this code on my setup, as well as on the following sites: http://webcompiler.cloudapp.net/ (claims VS compiler version 19, also prints "true"), http://codepad.org/ , http://www.tutorialspoint.com/compile_cpp_online.php , and a few others.

I'm not sure what the correct behavior here is, or whether the code below is actually correct C++ code, so I'm quite stumped. If anyone could shed some light on what is going here, that would be fantastic.

#include <stdio.h> #include <typeinfo> template <typename T> struct foo { template <typename U> static void bar() {} }; template <typename T> void baz() { puts(typeid(&foo<T>::template bar<int>) == typeid(int) ? "true" : "false"); } int main() { baz<double>(); }

Edit:

Thanks to Reddit I managed to bring this bug to the attention of STL, who says he has reported it and it will be fixed in the VS 2015 RTM: http://www.reddit.com/r/cpp/comments/2zs2ob/vc_2015_rtm_what_do_you_want_it_to_have/cpm01wr