Microsoft KB Archive/320004

= FIX: &quot;Fatal Error C1001&quot; Error Message When You Compile Code with While Loop =

Article ID: 320004

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft Visual C++ .NET 2002 Standard Edition

-



This article was previously published under Q320004



SYMPTOMS
When you try to compile code that is similar to the sample code included in the &quot;Steps to Reproduce the Problem&quot; section of this article, you may receive the following error message:

&quot;fatal error C1001: INTERNAL COMPILER ERROR

(compiler file 'f:\vs70builds\9466\vc\Compiler\Utc\src\P2\main.c', line 146)&quot;



CAUSE
This behavior occurs because the optimizing compiler cannot optimize the while loop.



RESOLUTION
To work around the issue, use one of the following methods:  Turn off the /Og switch for the function by using the following command:

#pragma optimize(&quot;g&quot;,off)

-or- Declare the function parameter start to be 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 Problem
Try to compile the following code: //test.cpp // Compiler Option: cl /c /Og test.cpp

union Pixel{ char code8; } ;

struct RGB { double r; }; //#pragma optimize(&quot;g&quot;,off)//WORKAROUND 1

void func(  char *start, char *end) //void func(  volatile char *start, char *end) //WORKAROUND 2 {    RGB map[256]; Pixel s[16];

while (start < end) { *start++ = s[(int)((map[*start].r))].code8;

} } You receive the error message described in the &quot;Symptoms&quot; section of this article.
 * 1) pragma optimize(&quot;&quot;,on) //WORKAROUND 1

Additional query words: Og ICE KbCpp KbNative KBUnmanaged

Keywords: kberrmsg kbbug kbfix kbpending kbcompiler KB320004

-

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

© Microsoft Corporation. All rights reserved.