Constructing a varargs CallInst

I'm trying to use CallInst::Create to construct a call to a variadic function, and I'm running into the following assertion failure:

/localhome/simmon12/workspace/llvm-sources/lib/VMCore/Instructions.cpp:297: void llvm::CallInst::init(llvm::Value*, llvm::Value* const*, unsigned int): Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) == Params[i]->getType()) && "Calling a function with a bad signature!"' failed.

I'm using the version of CallInst taking the beginning and end iterators of a vector<Value*>. I made sure to mark the function declaration with varargs=true when I created it (the function definition itself is in an external library). Is there anything different or special I need to do not to run into this type error?

--Patrick

Hi Patrick,

I'm trying to use CallInst::Create to construct a call to a variadic
function, and I'm running into the following assertion failure:

/localhome/simmon12/workspace/llvm-sources/lib/VMCore/Instructions.cpp:297:
void llvm::CallInst::init(llvm::Value*, llvm::Value* const*, unsigned
int): Assertion `(i>= FTy->getNumParams() || FTy->getParamType(i) ==
Params[i]->getType())&& "Calling a function with a bad signature!"' failed.

one of the parameters you are passing does not have the right type.
If you run in gdb, you can do:
   call FTy->getParamType(i)->dump()
and
   call Params[i]->getType()->dump()
to see what's going on.

Ciao,

Duncan.