BUG: Too many unnested loops incorrectly causes a C1061 compiler error in Visual Studio .NET (315481)



The information in this article applies to:

  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2002), Academic Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Professional Edition

This article was previously published under Q315481

SYMPTOMS

If a function contains more than approximately 250 unnested loops, you receive the following error message, which should not appear in this scenario:
"fatal error C1061: compiler limit : blocks nested too deeply"
The problem occurs only when you compile the source code as a C++ source file. The source code compiles without errors when you compile the source code as a C source file.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce the Behavior

The following sample code demonstrates the error:
/* Compile options needed: /TP /c
*/ 
#include <stdio.h>

// The code blocks in this function have only two nesting levels. 
// C1061 should not occur.
void func1()
{
	int a;
	int i = 0;
	int count = 0;

	count++;
	a = count;
	for (i=0; i<5; i++) {
		a += a*i;
	}
	printf("a=%d\n", a);

	// Copy and paste the following code 250 times.
	/*
	for (i=0; i<5; i++) {
		a += a*i;
	}
	printf("a=%d\n", a);
	*/ 

	count++;
	a = count;
	for (i=0; i<5; i++) {
		a += a*i;
	}
	printf("a=%d\n", a);
}

void main(){
	func1();
}
				

Modification Type:MinorLast Reviewed:8/24/2005
Keywords:kbvs2002sp1sweep kbbug kbCompiler kbpending KB315481