C++ 指针立即变为空
我有以下LLVM代码。奇怪的是,类型为C++ 指针立即变为空,c++,C++,我有以下LLVM代码。奇怪的是,类型为StoreInst的si变量在if块外分配了新指令后立即变为null(0),而我在外部范围声明了它。这是怎么回事 Value *OldVal = NULL; StoreInst* si = NULL; if ( ... ) { if ( ... ) { .... if ( ...
StoreInst
的si
变量在if块外分配了新指令后立即变为null(0),而我在外部范围声明了它。这是怎么回事
Value *OldVal = NULL;
StoreInst* si = NULL;
if ( ... )
{
if ( ... )
{
....
if ( ... )
{
...
StoreInst* si = new StoreInst(...);
errs() << "si = " << si << "\n"; // Get some address here
}
errs() << "-->SI = " << si << "\n"; // Here I get NULL, why?
}
...
}
StoreInst*si=newstoreinst(…)代码>-您在此处隐藏了previos名称si
当作用域结束时
}-您将看到另一个指针的值
以下是您所做工作的示例:
int val = 0; //first val
{
int val = 10; //other val (let's call it second)
cout << val; //second val
} // second val is destroyed here
cout << val; //first val
int val=0//第一节
{
int val=10;//其他val(我们称之为秒)
库特
int val = 0; //first val
{
int val = 10; //other val (let's call it second)
cout << val; //second val
} // second val is destroyed here
cout << val; //first val