BUG: Compiler Omits C4758 and/or C4762 Warnings

Last reviewed: July 22, 1997
Article ID: Q115326
7.00 | 1.00 1.50 MS-DOS | WINDOWS kbtool kbbuglist

The information in this article applies to:

  • The Microsoft C/C++ Compiler (CL.EXE), included with:

        - Microsoft C/C++ for MS-DOS, version 7.0
        - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
    

SYMPTOMS

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.

RESOLUTION

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.

MORE INFORMATION

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.

Sample Code

/* 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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.