FIX: Compiling with the */Og Switch Causes C1001, lur.c, Line 5960 (320003)



The information in this article applies to:

  • Microsoft Visual C++ .NET (2002)

This article was previously published under Q320003

SYMPTOMS

If you compile code similar to that shown in the "Steps to Reproduce the Behavior" section, you may receive the following error message:
fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'f:\vs70builds\9466\vc\Compiler\Utc\src\P2\lur.c', line 5960)

CAUSE

The Optimizing Compiler is trying to unroll the for loop, and failing.

RESOLUTION

Use either one of the following workarounds:
  • Turn off the /Og switch for the function by using:
    #pragma optimize("g",off)
    					
    -or-

  • Declare the local variables (s or r) volatile.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article. This bug was corrected in Microsoft Visual C++ .NET (2003).

MORE INFORMATION

Steps to Reproduce the Behavior

To reproduce the problem, run the following code sample:
  
//test.cpp
// Compiler Option: cl /c /Og test.cpp

struct A{double x;};
struct B{
unsigned int size;
A* samples;
};
 
//#pragma optimize("g",off)//WORKAROUND 1

void test(B* pB)
{
 	int s;
	//volatile int s;  //WORKAROUND 2
	int r;
	s = pB->size;
		for(r = (pB->size - 1);s < r;r--){
		    pB->samples[r].x = pB->samples[r - 1].x;
		}
	}
//#pragma optimize("",on) //WORKAROUND 1
				

Modification Type:MinorLast Reviewed:7/5/2005
Keywords:kbfix kbbug kbCompiler kbpending KB320003