Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Warning C4972

Error Message

Directly modifying or treating the result of an unbox operation as an lvalue is unverifiable

Dereferencing a handle to a value type, also known as unboxing, and then assigning to it is not verifiable.

For more information, see Implicit Boxing.


The following sample generates C4972.

// C4972.cpp
// compile with: /clr:safe
using namespace System;
ref struct R {
   int ^ p;   // a value type

int main() {
   R ^ r = gcnew R;
   *(r->p) = 10;   // C4972

   // OK
   r->p = 10;
   Console::WriteLine( r->p );
   Console::WriteLine( *(r->p) );

Community Additions

© 2015 Microsoft