BUG: Incorrect P-Code Generated for Large Integer Constant

Last reviewed: July 17, 1997
Article ID: Q92730
7.00 7.00a | 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

In Microsoft C/C++ version 7.0 and Microsoft Visual C++ 1.0, using large constants in an arithmetic expression causes the compiler to generate erroneous code without issuing a warning or error message when the /Oq compiler option switch is specified.

CAUSE

The compiler is unable to correctly process a integer constant that is too large to be represented by a signed integer.

RESOLUTION

Append the "L" suffix to the large integer constant to create a long constant. Doing so promotes other integers in the expression to type long as well.

STATUS

Microsoft has confirmed this to be a problem in CL.EXE versions 7.0, 7.0a, and 8.0. We are researching this problem, and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Sample Code:

/*
 * To demonstrate this error, compile the code below with both the /Oq
 * and /Fc compiler options. The /Fc option instructs the compiler to
 * generate a code listing.
 */

void main ( void )
{
   int i, j = -32009;

   i = j - 0x8001;         // to correct use:  i = j - 0x8001L;
   printf("i = %d\n", i);
}

The code listing does not indicate the incorrect integer constant.


Additional reference words: 7.00 8.00 8.00c 1.00 1.50
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 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.