FIX: C1001: reg86.c:1.26, line 3154, Converting Short to Char

Last reviewed: September 18, 1997
Article ID: Q115534
1.00 WINDOWS kbtool kbfixlist kbbuglist

The information in this article applies to:

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

        - Microsoft Visual C++ for Windows, version 1.0
    

SYMPTOMS

Using global register and global code optimization when converting a short variable to a character, illustrated in the sample source code below (in the "MORE INFORMATION" section), causes the compiler to generate the following error:

      fatal error C1001: internal compiler error
          (compiler file '@(#)reg86.c:1.26', line 3154)

RESOLUTION

There are three workarounds to this problem:

  • Use the fast compiler option, /f.

    -or-

  • Disable optimization using #pragma optimize("",off) before the function and #pragma optimize("",on) after the function containing the error.

    -or-

  • In the case of the source code below, use a temporary variable to store the converted value:

          BYTE temp=(BYTE)dry;
    

          BltRrc(pwnd, 0, 0, rrc.rxRight, (BYTE) (ryBottom - dry), 0, temp);
    

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed above. This problem was corrected in Visual C++ version 1.5.

MORE INFORMATION

The following sample code can be used to demonstrate this problem:

Sample Code

/* Compile options needed: /Oge /AS /c
*/
      typedef unsigned char BYTE;
      typedef unsigned short BOOL;
      typedef unsigned short WORD;
      typedef unsigned BITS;
      typedef BYTE RX;
      typedef BYTE RY;

      typedef struct _rrc
      {
       BYTE    ryTop;
       BYTE    rxRight;
       BYTE    ryBottom;
      } RRC;

      typedef struct _wnd
      {
       WORD    id;
       BITS    style:14;
       BITS    fCursorOn:1;
       BITS    fEnabled:1;
       WORD    rgwExtra[1];
      } WND;

      typedef WND *PWND;

      void far pascal BltRrc(PWND, RX, RY, BYTE, BYTE, RX, RY);

      void ScrollListBox(PWND pwnd,short dry,BOOL fKillOld)
      {
       WORD    iszTop;
       RRC     rrc;
       WORD    iszBottom;
       short   iszNewTop;
       short   iszNewBottom;
       WORD    ryBottom;

       iszTop = pwnd->rgwExtra[1+3];
       ryBottom = rrc.ryBottom;
       iszBottom = iszTop + ryBottom - 1;
       iszNewTop = iszTop + dry;
       iszNewBottom = iszBottom + dry;
       dry = iszNewTop - iszTop;

       BltRrc(pwnd, 0, 0, rrc.rxRight, (BYTE) (ryBottom - dry),
           0, (BYTE) dry);
      }


Additional reference words: 8.00 1.00
KBCategory: kbtool kbfixlist kbbuglist
KBSubcategory: CLIss
Keywords : CLIss kb16bitonly kbbuglist kbfixlist kbtool
Version : 1.00
Platform : WINDOWS
Solution Type : kbfix


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: September 18, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.