ID: Q115702
6.00 6.00a 7.00 | 1.00 1.50
MS-DOS | WINDOWS
kbtool kbbuglist
The information in this article applies to:
- Microsoft C for MS-DOS, versions 6.0, 6.0a, and 6.0ax
- Microsoft C/C++ for MS-DOS, version 7.0
- Microsoft Visual C++ for Windows, versions 1.0 and 1.5
The use of the /Oc optimization (Enable Block-Common Subexpression Optimization) on inline assembly code which uses the stack may corrupt the stack. The source code below can be used to illustrate this problem.
There are two workarounds to this problem:
1. Use the fast compiler option /f if you are using the C/C++ version 7.0
or later, or else use the /qc option if using earlier versions.
-or-
2. Disable optimization during the function by using the optimize pragma:
#pragma optimize("",off)
void bad_function(void)
{
/* ... */
}
#pragma optimize("",on)
Microsoft has confirmed this to be a bug in the Microsoft products listed above. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
This is not a problem in Visual C++, 32-bit Edition.
The following code can be used to demonstrate this problem.
/* Compile options needed: /c /Oc
*/
void _cdecl b(int c,int d);
void a(void)
{
_asm pushf
_asm cli
b(1,2);
_asm popf
return;
}
Additional reference words: 6.00 6.00a 7.00 8.00 8.00c 1.00 1.50
KBCategory: kbtool kbbuglist
KBSubcategory: CLIss
Keywords : kb16bitonly
Last Reviewed: July 23, 1997