Microsoft KB Archive/320003

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

Article ID: 320003

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft Visual C++ .NET 2002 Standard Edition

-



This article was previously published under Q320003



SYMPTOMS
If you compile code similar to that shown in the &quot;Steps to Reproduce the Behavior&quot; 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: -or-
 * 1) pragma optimize(&quot;g&quot;,off)

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



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(&quot;g&quot;,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(&quot;&quot;,on) //WORKAROUND 1

Additional query words: Og ICE KbCpp KbNative KBUnmanaged

Keywords: kbbug kbfix kbpending kbcompiler KB320003

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.