Skip to content

Latest commit

 

History

History
39 lines (29 loc) · 1.32 KB

compiler-warning-c4957.md

File metadata and controls

39 lines (29 loc) · 1.32 KB
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Compiler Warning C4957
Compiler Warning C4957
11/04/2016
C4957
C4957
a18c52d4-23e2-44f1-b4b5-f7fa5a7f3987

Compiler Warning C4957

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

Remarks

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 (C++/CLI).

The /clr:safe compiler option is deprecated in Visual Studio 2015 and unsupported in Visual Studio 2017.

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

Example

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
}