<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I got a little problems with strings (const char pointers). Global variables holding the string literal are declared correctly, but i have a problem when I pass this string to a function: it asserts with this message.<div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class="">Assertion failed: ((i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"), function init, file llvm-3.8.0.src/lib/IR/Instructions.cpp, line 245.</b></span></div><div class=""><br class=""></div><div class="">Function declaration in the IR:</div><div class=""><b style="font-family: Menlo; font-size: 11px;" class="">; Function Attrs: nounwind ssp uwtable</b></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><b class="">declare i32 @_wrts(i8*) #0</b></span></div><div class=""><br class=""></div><div class="">All the types match (even if the assertion condition makes me think they shouldn’t), am I doing something wrong with GEP?</div><div class="">here’s the code that translates the AST Literal into LLVM IR and creates the GEP (the return value will be passed to the Callee):</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">llvm</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">::</span><span style="font-variant-ligatures: no-common-ligatures" class="">Value</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> *</span><span style="font-variant-ligatures: no-common-ligatures" class="">ast</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">::</span><span style="font-variant-ligatures: no-common-ligatures" class="">StringLiteral</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">::build(</span><span style="font-variant-ligatures: no-common-ligatures" class="">llvmir_builder</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> *builder) {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">TypeRef</span><span style="font-variant-ligatures: no-common-ligatures" class=""> *strtype = </span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">evalType</span><span style="font-variant-ligatures: no-common-ligatures" class="">();</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">TypeRef</span><span style="font-variant-ligatures: no-common-ligatures" class=""> *chrtype = strtype-></span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">getType</span><span style="font-variant-ligatures: no-common-ligatures" class="">()-></span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">getPointedType</span><span style="font-variant-ligatures: no-common-ligatures" class="">();</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">llvm</span><span style="font-variant-ligatures: no-common-ligatures" class="">::</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">ArrayType</span><span style="font-variant-ligatures: no-common-ligatures" class=""> *arty = </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">llvm</span><span style="font-variant-ligatures: no-common-ligatures" class="">::</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">ArrayType</span><span style="font-variant-ligatures: no-common-ligatures" class="">::</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">get</span><span style="font-variant-ligatures: no-common-ligatures" class="">(chrtype-></span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">getIRType</span><span style="font-variant-ligatures: no-common-ligatures" class="">(), </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">val</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">length</span><span style="font-variant-ligatures: no-common-ligatures" class="">()+</span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span><span style="font-variant-ligatures: no-common-ligatures" class="">);</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb42a3" class="">if</span><span style="font-variant-ligatures: no-common-ligatures" class=""> (!</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">strcst</span><span style="font-variant-ligatures: no-common-ligatures" class="">) {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">strcst</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb42a3" class="">new</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">llvm</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">::</span><span style="font-variant-ligatures: no-common-ligatures" class="">GlobalVariable</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(*</span><span style="font-variant-ligatures: no-common-ligatures" class="">container</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> arty,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb42a3" class="">true</span><span style="font-variant-ligatures: no-common-ligatures" class="">,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">llvm</span><span style="font-variant-ligatures: no-common-ligatures" class="">::</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">GlobalValue</span><span style="font-variant-ligatures: no-common-ligatures" class="">::</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">PrivateLinkage</span><span style="font-variant-ligatures: no-common-ligatures" class="">,</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">llvm</span><span style="font-variant-ligatures: no-common-ligatures" class="">::</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">ConstantDataArray</span><span style="font-variant-ligatures: no-common-ligatures" class="">::</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">getString</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">container</span><span style="font-variant-ligatures: no-common-ligatures" class="">-></span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">getContext</span><span style="font-variant-ligatures: no-common-ligatures" class="">(), </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">val</span><span style="font-variant-ligatures: no-common-ligatures" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">c_str</span><span style="font-variant-ligatures: no-common-ligatures" class="">()),</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #d12f1b" class="">".str"</span><span style="font-variant-ligatures: no-common-ligatures" class="">);</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(49, 89, 93);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">strcst</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">-></span><span style="font-variant-ligatures: no-common-ligatures" class="">setUnnamedAddr</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #bb42a3" class="">true</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">);</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">strcst</span><span style="font-variant-ligatures: no-common-ligatures" class="">-></span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">setAlignment</span><span style="font-variant-ligatures: no-common-ligatures" class="">(chrtype-></span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">getByteSize</span><span style="font-variant-ligatures: no-common-ligatures" class="">());</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #bb42a3" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> builder-></span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">CreateInBoundsGEP</span><span style="font-variant-ligatures: no-common-ligatures" class="">(arty, </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">strcst</span><span style="font-variant-ligatures: no-common-ligatures" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">llvm</span><span style="font-variant-ligatures: no-common-ligatures" class="">::</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">ConstantInt</span><span style="font-variant-ligatures: no-common-ligatures" class="">::</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">get</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">llvm</span><span style="font-variant-ligatures: no-common-ligatures" class="">::</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Type</span><span style="font-variant-ligatures: no-common-ligatures" class="">::</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">getInt8Ty</span><span style="font-variant-ligatures: no-common-ligatures" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">container</span><span style="font-variant-ligatures: no-common-ligatures" class="">-></span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">getContext</span><span style="font-variant-ligatures: no-common-ligatures" class="">()), </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0</span><span style="font-variant-ligatures: no-common-ligatures" class="">));</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div></div></body></html>