BUG: C2443 Using Structure Member Operand in _asm Block

Last reviewed: July 24, 1997
Article ID: Q125799
The information in this article applies to:
  • The Microsoft C/C++ Compiler (CL.EXE), included with: - Microsoft Visual C++ for Windows, versions 1.0, 1.5, 1.51 - Microsoft Visual C++, 32-bit Edition, versions 1.1, 2.0, 2.1, 4.0,

         4.1, 4.2, 5.0 on the following platform:
         - x86
    

SYMPTOMS

Under the four conditions described in this article, the following compiler error is generated:

   test.cpp(linenumber) : error C2443: operand size conflict

Here linenumber is the assembly instruction in TEST.CPP file that meets the following conditions. This error occurs when the following four conditions are met:
  • You're using inline assembly.
  • The size of the source operand on an assembly instruction is different from the size of the destination operand.
  • The source operand is a member of a structure.
  • The PTR operator is used to force the operand to the size required.

RESOLUTION

If you are using C++, declare a reference variable initialized with the structure member. Use the reference variable as the source operand in the assembly instruction as shown in this sample code:

Sample Code

   /* Compile options needed: /Tp
   */

   struct Test
   {
     int  nInt;
   } test1;

   void main(void)
   {
   __asm  mov  bh, BYTE PTR test1.nInt  /* error occurs here */

   int & nTest = test1.nInt;   /*  these lines work  */

   __asm  mov  bh, BYTE PTR nTest   /*  these lines work  */
   }

If you are using C, use a local variable instead of a reference variable.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


Keywords : CLngIss kbcode vcbuglist400 vcbuglist500
Version : 1.0 1.5 1.51 1.1 2.0 2.1 4.0 4.1
Platform : NT WINDOWS
Issue type : kbbug


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