Skip to content

Latest commit

 

History

History
38 lines (30 loc) · 867 Bytes

compiler-warning-c4972.md

File metadata and controls

38 lines (30 loc) · 867 Bytes
description title ms.date f1_keywords helpviewer_keywords ms.assetid
Learn more about: Compiler Warning C4972
Compiler Warning C4972
11/04/2016
C4972
C4972
d18e8e65-b2ef-4d75-a207-fbd0c17c9060

Compiler Warning C4972

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 Boxing.

Example

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