FIX: Bad Code Is Generated with /Og Enabled (281424)
The information in this article applies to:
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0 SP4
- Microsoft Visual C++, 32-bit Professional Edition 6.0 SP4
- Microsoft Visual C++, 32-bit Learning Edition 6.0 SP4
This article was previously published under Q281424 SYMPTOMS
With the global optimizations (/Og) compiler option enabled, the Visual C++ 6.0 Service Pack 4 (SP4) compiler may generate incorrect code for return values to functions. See the "More Information" section for a detailed reproducible sample.
CAUSE
This is a regression bug that occurred in Visual Studio Service Pack 4.
RESOLUTION
To work around this bug, do one of the following:
- Replace the following line in the sample code
Test (MyClass::Testfunc(), y, z);
with the following:
MyClass x = MyClass::Testfunc();
Test (x , y, z);
-or-
- In the sample code, use #pragma optimize("g", off) before the main function to disable the optimizations only in main.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
This problem was corrected in Visual Studio 6.0 ServicePack 5.
Modification Type: | Major | Last Reviewed: | 11/18/2003 |
---|
Keywords: | kbbug kbCompiler kbfix kbVC600fix KB281424 |
---|
|