编译器警告 C4972

直接修改取消装箱操作的结果或将其视为左值是不可验证的

取消引用值类型的句柄(也称为取消装箱),然后为其赋值,是不可验证的。

有关更多信息,请参见 装箱中定义的接口的私有 C++ 特定实现。

示例

下面的示例生成 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) );
}