Microsoft KB Archive/318139

= Incorrect Global Value Initialization If You Use Precompiled Header =

Article ID: 318139

Article Last Modified on 10/11/2005

-

APPLIES TO


 * Microsoft Visual C++ .NET 2002 Standard Edition

-



This article was previously published under Q318139



SYMPTOMS
If you use a precompiled header (such as /Yu, /Yx, or /Yc), global values may not be initialized correctly.



RESOLUTION
A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Microsoft Visual Studio .NET service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

NOTE: In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The typical support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The English version of this fix should have the following file attributes or later:   Date         Time    Version      Size       File name   Platform -  07-Mar-2002  15:57   13.00.9478   2,105,344  C1xx.dll    x86 07-Mar-2002 15:57   13.00.9478   1,757,184  C2.dll      x86



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



Steps to Reproduce the Behavior
  Create a new file named IncludeFile1.h, add the following code to IncludeFile1.h, and then save the file: const double gVal1 = 1234.567; const double gVal2 = gVal1;   Create a new file named IncludeFile2.h, add the following code to IncludeFile2.h, and then save the file: const double gVal3 = 10 * gVal2;   Create a new file named Stdafx.h, add the following code to Stdafx.h, and then save the file:   Create a new file named Stdafx.cpp, add the following code to Stdafx.cpp, and then save the file:  Use the following C++ compiler option on Stdafx.cpp:
 * 1) include &quot;IncludeFile1.h&quot;
 * 1) include &quot;Stdafx.h&quot;

/Yc&quot;stdafx.h&quot;

</li>  Create a new file named MyFile.cpp, add the following code to MyFile.cpp, and then save the file: </li> Use the following C++ compiler option on MyFile.cpp:
 * 1) include &quot;stdafx.h&quot;
 * 2) include &quot;IncludeFile2.h&quot;

/Yu&quot;stdafx.h&quot;

Notice that //gVal3 is incorrectly initialized for use in MyFile.cpp.</li></ol>

Keywords: kbbug kbfix kbqfe kbcompiler kbhotfixserver KB318139

-

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

© Microsoft Corporation. All rights reserved.