Article ID: 125799 - Last Review: July 5, 2005 - Revision: 2.1

FIX: C2443 Using Structure Member Operand in _asm Block

This article was previously published under Q125799

On This Page

Expand all | Collapse all

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

truct 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

This bug was corrected in Microsoft Visual C++, version 6.0.

APPLIES TO
  • Microsoft Visual C++ 1.0 Professional Edition
  • Microsoft Visual C++ 2.0 Professional Edition
  • Microsoft Visual C++ 2.1
  • Microsoft Visual C++ 4.0 Standard Edition
  • Microsoft Visual C++ 4.1 Subscription
  • Microsoft Visual C++ 4.2 Enterprise Edition
  • Microsoft Visual C++ 4.2 Professional Edition
  • Microsoft Visual C++ 5.0 Enterprise Edition
  • Microsoft Visual C++ 5.0 Professional Edition
  • Microsoft Visual C++ 1.5 Professional Edition
  • Microsoft Visual C++ 1.52 Professional Edition
Keywords: 
kbbug kbfix kbvc600fix KB125799
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
 

Article Translations