可能的 Visual Studio 2015 C++ 编译器和 IntelliSense 错误

Possible Visual Studio 2015 C++ Compiler and IntelliSense Bugs

我在使用 C++ 的 Visual Studio 2015 中遇到编译器崩溃和智能感知误报。

在函数块中编写时,这会使编译器崩溃:

if();

这是编译时显示的对话框(我使用的是德文版 Windows):

即使编译器崩溃,我也得到错误列表输出:

Error C2059 syntax error: ')'
Warning C4390 ';': empty controlled statement found; is this the intent?
Error C1903 unable to recover from previous error(s); stopping compilation

这会在地图模式下的垂直滚动条中产生波浪线和错误注释,但不会产生实际的智能感知错误:

#include <vector>

struct S { std::vector<S> Children; };

int main(int argc, char* argv[]) {
    S item;

    item.Children.push_back(S());
    //           ^
    // Error: no instance of overloaded function 
    // "std::vector<_Ty, _Alloc>::push_back [with _Ty=S, _Alloc=std::allocator<S>]" 
    // matches the argument list
    // argument types are: (S)
    // object type is: std::vector<S, std::allocator<S>>

    S& back = item.Children.back();
    //        ^^^^
    // Error: a reference of type "S &" (not const-qualified) cannot be
    // initialized with a value of type "S"

    return 0;
}

那些是错误吗?他们知道吗?你能复制它们吗?

对于第一种情况:编译器不应该崩溃,而只是发出您显示的诊断信息。所以是的,这是一个错误。顺便说一句,在 VS2013 中不会发生。提交报告 here

第二种情况:在VS2013中也是一样,是因为在S中嵌套了一个S的向量。这种情况和其他情况导致错误的波浪线出现不正确,其实并不少见。但理想情况下,它不应该发生,因此您也可以为其提交错误报告,尽管它可能会被标记为 'wontfix',因为编译器团队通常专注于更紧急的情况。