Incorrect Global Value Initialization If You Use Precompiled Header

Article translations Article translations
Article ID: 318139 - View products that this article applies to.
This article was previously published under Q318139
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all

On This Page

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.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. 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;
    					
  2. Create a new file named IncludeFile2.h, add the following code to IncludeFile2.h, and then save the file:
    const double gVal3 = 10 * gVal2;
    					
  3. Create a new file named Stdafx.h, add the following code to Stdafx.h, and then save the file:
    #include "IncludeFile1.h"
    					
  4. Create a new file named Stdafx.cpp, add the following code to Stdafx.cpp, and then save the file:
    #include "Stdafx.h"
    					
  5. Use the following C++ compiler option on Stdafx.cpp:
    /Yc"stdafx.h"
  6. Create a new file named MyFile.cpp, add the following code to MyFile.cpp, and then save the file:
    #include "stdafx.h"
    #include "IncludeFile2.h"
    					
  7. Use the following C++ compiler option on MyFile.cpp:
    /Yu"stdafx.h"
    Notice that //gVal3 is incorrectly initialized for use in MyFile.cpp.

Properties

Article ID: 318139 - Last Review: October 24, 2013 - Revision: 1.3
APPLIES TO
  • Microsoft Visual C++ .NET 2002 Standard Edition
Keywords: 
kbnosurvey kbarchive kbbug kbfix kbqfe kbcompiler kbhotfixserver KB318139

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com