Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)?

like image 895
0xC0000022L Avatar asked Jan 26 '26 01:01

0xC0000022L


1 Answers

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.

like image 90
Lundin Avatar answered Jan 27 '26 17:01

Lundin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!