编译器警告 C4972
更新:2007 年 11 月
错误消息
直接修改取消装箱操作的结果或将其视为左值是不可验证的
取消引用对值类型的处理(也称为取消装箱),然后为其赋值,是不可验证的。
有关更多信息,请参见 Implicit Boxing。
示例
下面的示例生成 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) );
}