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

Compiler Warning C4957

Error Message

'cast' : explicit cast from 'cast_from' to 'cast_to' is not verifiable

A cast will result in an unverifiable image.

Some casts are safe (for example, a static_cast that triggers user-defined conversions and a const_cast). A safe_cast is guaranteed to produce verifiable code.

For more information, see Pure and Verifiable Code.

This warning is issued as an error and can be disabled with the warning pragma or the /wd compiler option.

The following sample generates C4957:

// C4957.cpp
// compile with: /clr:safe
// #pragma warning( disable : 4957 )
using namespace System;
int main() {
   Object ^ o = "Hello, World!";
   String ^ s = static_cast<String^>(o);   // C4957
   String ^ s2 = safe_cast<String^>(o);   // OK
}

Community Additions

ADD
Show:
© 2015 Microsoft