Compiler Warning (level 1) C4383
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

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.


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;
© 2015 Microsoft