Microsoft (R) Optimizing Compiler Has Stopped Working

Started by
3 comments, last by Khatharr 11 years, 5 months ago
Hello,

I have just received the error in the title when trying to compile the following code

auto ExtractString = [&](string& dest, char source, FileSection& currentFileSection, FileSection nextFileSection = END_OF_HEADER)
{ ... };

Just for context, I am writing a custom file format parser.

Am I just hosed here, or is there some way to work around a broken compiler?

Thanks and best,

Dave

I wonder as I wander...

http://www.davesgameoflife.com

Advertisement
Check your lambda capture syntax (the [&] stuff).

Alternatively, use a conventional function (and its pointer) in place of the lambda expression.

Niko Suni

What is the minimal source file that reproduces the error?

For example, I get "error C3486: a parameter for a lambda cannot have a default argument" with the following code:

#include <string>

using std::string;

enum FileSection {
START_OF_HEADER,
END_OF_HEADER
};

int main() {
auto ExtractString = [&](string& dest, char source, FileSection& currentFileSection, FileSection nextFileSection = END_OF_HEADER) {
};
std::string string;
FileSection current = START_OF_HEADER;
ExtractString(string, 'a', current);
}

Some light Googling suggests this is actually compliant with the standard and not an incomplete implementation.

It would be interesting to know what changes you have to make to generate the crash. Even if it is not legal code, it shouldn't crash the compiler so you should look into reporting this.
While I have found sporadically code that could crash an MSVC compiler in practically every instance it was rather clear that the code was wrong and needed to be fixed anyway (admittedly, that would have been easier with a proper error message).

That said, such cases have always been extremely rare for me. Infrequently the compiler crashes, but usually that is fixed by just trying again or doing a clean first. There was one instance where I had to manually (clean or rebuild explicitly did not do the job) delete all intermediate files to get things working again, but that was back in MSVC 2003.
Yeah, I tanked it once myself, though now I can't remember what it was I did. (It was something really crazy that came out of a typo.)

I just remember laughing for about 10 minutes about it.

Your compiler is fine. It's just a microsoft product.
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

This topic is closed to new replies.

Advertisement