FIX: Nested Loops Cause Internal Compiler Error in msc1.cpp

ID: Q115537

1.00 WINDOWS kbtool kbfixlist kbbuglist

The information in this article applies to:

SYMPTOMS

Compiling code that contains deeply nested loops, as demonstrated in the sample source code in the "MORE INFORMATION" section below (which contains 16 nested loops), produces the following internal compiler error, regardless of the command-line optimizations used:

      fatal error C1001: internal compiler error
                         (compiler file 'msc1.cpp', line 581)

RESOLUTION

If possible, change the source code to reduce the number of nested loops.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed above. This problem was corrected in Visual C++ version 1.5.

MORE INFORMATION

With the Microsoft C compiler, version 6.0, the sample code below causes a C1026 "parser stack overflow, program too complex" error to be generated. No errors or warnings are generated with the C/C++ compiler, version 7.0. The C1001 error is generated with C/C++, version 8.0.

Sample Code

/* Compile options needed: none
*/ 
      void main(void)
      {
       int i = 0;

       for(;i<2;)
        for(;i<2;)
         for(;i<2;)
          for(;i<2;)
           for(;i<2;)
            for(;i<2;)
             for(;i<2;)
              for(;i<2;)
               for(;i<2;)
                for(;i<2;)
                 for(;i<2;)
                  for(;i<2;)
                   for(;i<2;)
                    for(;i<2;)
                     for(;i<2;)
                      for(;i<2;)
                         i = 2;   /* error occurs on this line */ 
      }

Additional reference words: 8.00 1.00 KBCategory: kbtool kbfixlist kbbuglist KBSubcategory: CLIss
Keywords          : kb16bitonly kbCompiler kbbuglist kbfixlist
Version           : 1.00
Platform          : WINDOWS
Solution Type     : kbfix

Last Reviewed: September 22, 1997