0xC0000022L
0xC0000022L

Reputation: 21269

VS2015 error C1026 - a compiler defect?

So with C code that doesn't bother VS2013 and earlier at all, we are getting the following error with VS2015 (Update 1):

fatal error C1026: parser stack overflow, program too complex

The code is a bit iffy in that it uses loads -- I stopped counting beyond 200 -- of if-else if statements inside one outer if, inside a while-loop. The developer responsible for that piece of code is somewhat stuck in mid-1980s ways. But the project is fortunately only used for one internal tool.

Example (due to obvious misconceptions in comments and first answer):

while(whatever)
{
    if(some_condition)
    {
        if(condition1)
            do_something1();
        else if(condition2)
            do_something2();
        else if(condition3)
            do_something3();
        else if(condition4)
            do_something4(); /* more than two hundred more `else if` */
    }
}

Anyway, since the older versions of VS are not bailing on that code, am I to assume that this is a newly introduced compiler defect which I should report to Microsoft (e.g. via Connect)?

Upvotes: 3

Views: 1054

Answers (1)

Lundin
Lundin

Reputation: 213693

The current C standard only guarantees 127 levels of nested blocks. The 1980s version of C only guaranteed 15 levels. Writing programs that aren't in accordance with the C standard is the core problem here.

Anyway, this seems to be a confirmed bug in VS2015.

Upvotes: 3

Related Questions