Compiler Error C2452
'type' : invalid source type for safe_cast
The source type for safe_cast was not valid. For example, all types in a safe_cast
operation must be CLR types.
The following sample generates C2452:
// C2452.cpp
// compile with: /clr
struct A {};
struct B : public A {};
ref struct C {};
ref struct D : public C{};
int main() {
A a;
safe_cast<B*>(&a); // C2452
// OK
C ^ c = gcnew C;
safe_cast<D^>(c);
}
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for