Search code examples
c++intellisensevisual-studio-2015compiler-bug

Possible Visual Studio 2015 C++ Compiler and IntelliSense Bugs


I encountered a compiler crash and intellisense false positives with Visual Studio 2015 using C++.

This crashes the compiler when written within a function block:

if();

This is the dialog that is shown when compiling (I am on a German version of Windows):

enter image description here

Even though the compiler crashes, I get error list output:

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

This produces squiggles and error annotations in the vertical scrollbar in map mode, but no actual intellisense errors:

#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;
}

Are those bugs? Are they known? Can you reproduce them?


Solution

  • For the first case: the compiler shouldn't crash but just issue the diagnostic you show. So yes, that's a bug. Which doesn't occur in VS2013 btw. Submit a report for it here

    For the second case: it is the same in VS2013 and is due to nesting a vector of S inside S. This and other cases make the error squiggles appear incorrectly, it is actually not that uncommon. But ideally it should not happen so you can submit a bug report for it as well, though it might be something which is going to be labelled 'wontfix' as the compiler team usually focusses on more urgent cases.