Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Compiler Warning (level 1) C4669
Collapse the table of content
Expand the table of content

Compiler Warning (level 1) C4669

Error Message

'cast' : unsafe conversion: 'class' is a managed type object

A cast contains a managed type. The compiler completes the cast by performing a bit wise copy of one pointer to the other, but provides no other checking. To resolve this warning, do not cast classes containing managed members.

The following sample generates C4669:

// C4669.cpp
// compile with: /clr /W1
ref struct A {
   int i;
   Object ^ pObj;   // remove the managed member to resolve the warning
};

ref struct B {
   int j;
};

int main() {
   A ^ a = gcnew A;
   B ^ b = reinterpret_cast<B ^>(a);   // C4669
}

Community Additions

ADD
Show:
© 2015 Microsoft