Muokkaa

Jaa


Compiler Warning C4958

'operation' : pointer arithmetic is not verifiable

Remarks

Using pointer arithmetic will produce an unverifiable image.

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 C4958:

// C4958.cpp
// compile with: /clr:safe
// #pragma warning( disable : 4958 )
using namespace System;

int main( ) {
   Int32 arr[] = new Int32[10];
   Int32* p = &arr[0];
   p++;   // C4958
}

The compiler implements array operations with pointer arithmetic. Therefore, native arrays are not verifiable; use a CLR array instead. For more information, see array.

The following sample generates C4958:

// C4958b.cpp
// compile with: /clr:safe
// #pragma warning( disable : 4958 )

int main() {
   int array[5];
   array[4] = 0;   // C4958
}