ReplaceInstWithInst problem


In my source code, I have the following declaration char a[30];

When I’m running the following (Assuming that I is an instruction pointer pointing to the instruction to be replaced, i.e. %a = alloca [30 x i8], align 1):

ArrayType* arr = ArrayType::get(IntegerType::get(getGlobalContext(), 8), 10);
AllocaInst* pa = new AllocaInst(arr, “blah”);
BasicBlock::iterator ii(I);
ReplaceInstWithInst(I->getParent()->getInstList(), ii, pa);
Why am I running into Value::replaceAllUsesWith(llvm::Value
): Assertion New->getType() == getType() && “replaceAllUses of value with new value of different type!”’ ?