Article ID: 216181 - View products that this article applies to.
This article was previously published under Q216181
This article has been archived. It is offered "as is" and will no longer be updated.
With global optimization (/Og) enabled, the Visual C++ 6.0 compiler may generate incorrect code for functions that pass a structure by value. This manifests itself as a structure which appears to have incorrect values after being passed into the function.
Visual C/C++ functions make local copies of its arguments to be referenced during a function's execution. Under a few circumstances, global optimization can cause the stack space for the copy of the structure to be allocated without copying the field values.
Disable global optimizations. Global optimizations can be disabled for the entire project, or for a particular source file by removing /Og from either the project's release build compiler settings or an individual file's release build compiler settings.
NOTE: /O1 (minimize size) and /O2 (maximize speed) are composite switches that include /Og. If you are using /O1 or /O2 then disable global optimizations by adding /Og to the appropriate compiler settings.
Global optimization can also be disabled on a function by function basis via the use of #pragma optimize, as in the following example:
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 Visual Studio 6.0 Service Pack 3. For more information about Visual Studio service packs, please see the following articles in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/194022/EN-US/ )INFO: Visual Studio 6.0 Service Packs, What, Where, Why
(http://support.microsoft.com/kb/194295/EN-US/ )HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed
Contact us for more help