<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jan 17, 2011, at 5:01 PM, Rob Nikander wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi,<br><br>I'm trying to follow the advice from this message:<br><a href="http://lists.cs.uiuc.edu/pipermail/llvmdev/2008-October/017574.html">http://lists.cs.uiuc.edu/pipermail/llvmdev/2008-October/017574.html</a>,<br>to create a call instruction from a function pointer.  But I'm<br>getting...<br><br>   Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of<br>incompatible type!"),<br>   function cast, file /usr/local/include/llvm/Support/Casting.h, line 202.<br><br>Code snippets...<br><br>    id testfunc(id a, id b) { ... }<br>    ...<br>    FunctionType *fn_type = FunctionType::get(id_type, argtypes, false);<span class="Apple-tab-span" style="white-space:pre">       </span><br>    Value *fn = ConstantExpr::getIntToPtr(ConstantInt::get(int64_type,<br>reinterpret_cast<int64_t>(testfunc)), fn_type);<br>    return builder.CreateCall2(fn, arg0val, arg1val);   // <--<br>assertion fails here<br><br>What am I doing wrong?  I can paste more code if needed.<br></div></blockquote></div><br><div>One of the types doesn't match the types of what you are trying to pass.</div><div><br></div><div>You should debug which one it is and why the types aren't matching what</div><div>you think they should be.</div><div><br></div><div>-eric</div></body></html>