Compiler Warning (level 1) C4383
TOC
Collapse the table of content
Expand the table of content
The document is archived and information here might be outdated

Compiler Warning (level 1) C4383

Error Message

'instance_dereference_operator' : the meaning of dereferencing a handle can change, when a user-defined 'operator' operator exists; write the operator as a static function to be explicit about the operand

When you add a user-defined instance override of the dereference operator in a managed type, you potentially override the ability of the type's dereference operator to return the handle's object. Consider writing a static, user-defined dereference operator.

For more information, see ^ (Handle to Object on Managed Heap) and % (Tracking Reference).

Also, an instance operator is not available to other language compilers via referenced metadata. For more information, see User-Defined Operators.

Example

The following sample generates C4383.

// C4383.cpp
// compile with: /clr /W1

ref struct S {
   int operator*() { return 0; }   // C4383
};

ref struct T {
   static int operator*(T%) { return 0; }
}; 

int main() {
   S s;
   S^ pS = %s;

   T t;
   T^ pT = %t;
   T% rT = *pT;
}
Show:
© 2016 Microsoft