Skip to content

Latest commit

 

History

History
35 lines (27 loc) · 735 Bytes

compiler-error-c2452.md

File metadata and controls

35 lines (27 loc) · 735 Bytes
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Compiler Error C2452
Compiler Error C2452
11/04/2016
C2452
C2452
a4ec7642-6660-4c7a-9866-853d1cc67daf

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);
}