ID: Q115326
7.00 | 1.00 1.50 MS-DOS | WINDOWS kbtool kbbuglist
The information in this article applies to:
- Microsoft C/C++ for MS-DOS, version 7.0
- Microsoft Visual C++ for Windows, versions 1.0 and 1.5
When you pass the address of a local variable as an argument in a function call and use the /Aw compiler switch, the C/C++ compiler generates different warnings, depending on whether the optimizing compiler is used. There should be warnings generated, but they should be the same each time.
Under C/C++, version 7.0, if the optimizing compiler is used (compile with /f-), the following warning is generated for a .C file:
test.c(8) : warning C4762: near/far mismatch in argument :
conversion supplied
If the fast compiler option is used (/f), a different warning is
generated:
test.c(8) : warning C4758: address of automatic (local) variable
taken, DS != SS
Under the C/C++ compiler, versions 8.0 and 8.0c, if the optimizing
compiler is used, only the C4762 warning is generated. If the fast
compiler is used, both the C4758 and C4762 warnings are generated.
However, if a .CPP or a .CXX file is used, no warnings are generated
when using the /f- option.
Microsoft has confirmed this to be a bug in the products listed above. We are researching this problem and will post new information in the Microsoft Knowledge Base as soon as it becomes available.
The following sample can be used to demonstrate the problem. If the file is named TEST.C, warning C4762 is produced. If the file is named TEST.CPP, no warnings are produced.
/* Compile options needed: /ASw /c /f-
*/
void func( char * );
void test( void )
{
char sz[32];
func( sz );
}
Additional reference words: 1.00 1.50 7.00 8.00 8.00c KBCategory: kbtool kbbuglist KBSubcategory: CLIss Keywords : kb16bitonly
Last Reviewed: July 23, 1997