-2

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?

Beta Carotin
  • 1,659
  • 1
  • 10
  • 27
  • 2
    SO is not the place to file bug reports. I'm sure VS has its own bug tracker. – sashoalm Jul 21 '15 at 07:15
  • 2
    That first one's not what I'd call a crash, either. More like a controlled exit after refusing to be stupid. Sure, compiler could optimize it out and carry on, but maaaan... – user4581301 Jul 21 '15 at 07:21
  • @sashoalm All related "possible compiler bugs" questions have a positive rating. How do you explain that? – Beta Carotin Jul 21 '15 at 07:21
  • @BetaCarotin See http://meta.stackoverflow.com/questions/284708/what-can-we-do-with-questions-where-the-only-response-is-contact-the-vendor for reference. You're welcome to add your opinion to the discussion there about whether such questions should, or should not be asked here. – sashoalm Jul 21 '15 at 07:28
  • 1
    @BetaCarotin A question should cover one single topic. Yours has two unrelated ones. Also the first is not even very clear: you state *This crashes the compiler* yet all you show is a normal compiler diagnostic. That is not a crash? – stijn Jul 21 '15 at 07:31
  • @stijn They are both VS2015 problems. I don't consider those issues unrelated enough to open separate questions. Also, what do you want me to show? I assume you know what a program crash looks like. – Beta Carotin Jul 21 '15 at 07:37
  • @user4581301 I don't expect the compiler to optimize out a syntax error. It crashes, it does not terminate gracefully. – Beta Carotin Jul 21 '15 at 07:40
  • So you get something like a "cl.exe stopped working" dialog? – stijn Jul 21 '15 at 07:53
  • @stijn Yes. _Microsoft (R) C/C++ Optimizing Compiler has stopped working_ in my case. – Beta Carotin Jul 21 '15 at 07:56
  • @BetaCarotin I stand corrected. That is definitely a crash. – user4581301 Jul 21 '15 at 16:06

1 Answers1

1

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.

stijn
  • 34,664
  • 13
  • 111
  • 163