<div dir="ltr">I remembered it working on an older prototype version that I used.<div>I've checked the old version (it also uses mcjit, llvm 3.5 or 3.6, x64) and found the following:</div><div><br></div><div><div><span class="" style="white-space:pre">                    </span>try {</div><div><span class="" style="white-space:pre">                              </span>engine->runFunction(func, args);  <b>// exception is caught </b><span style="white-space:pre">                            </span></div><div><span class="" style="white-space:pre">                           </span>auto f = (double (*)())engine->getPointerToFunction(func); </div><div><span class="" style="white-space:pre">                            </span>auto d = f(); <b>// exception is not caught</b></div><div><span class="" style="white-space:pre">                        </span>}</div><div><span class="" style="white-space:pre">                  </span>catch (const MyEx& e) {</div><div><span class="" style="white-space:pre">                                </span>std::cout << " eval exp handler " << std::endl;</div><div><span class="" style="white-space:pre">                      </span>}</div><div><span class="" style="white-space:pre">                  </span>catch (...) {</div><div><span class="" style="white-space:pre">                              </span>std::cout << " unknown exp handler " << std::endl;</div><div><span class="" style="white-space:pre">                   </span>}</div></div><div><br></div><div>If you use the runFunction(), the exception does not get lost.</div><div>If you cast it and run the func ptr, the exception gets thrown but the exception is not caught.</div><div><br></div><div>For me I could make runFunction to work with my case, but whats the difference?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 21, 2016 at 7:15 PM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This sounds like <a href="https://llvm.org/bugs/show_bug.cgi?id=24233" target="_blank">https://llvm.org/bugs/show_bug.cgi?id=24233</a>.</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Thu, Jan 21, 2016 at 6:21 AM, koffie drinker via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Hi all,<div><br></div><div>I have the following code:</div><div><br></div><div>[use llvm to generate ir_func() ]</div><div><br></div><div>in side the ir_func() there's a call to a native cpp function that throws an exception.</div><div>(Just imagine changing the fibonacci example and calling a native c++ func that throws inside the fibonacci body)</div><div><br></div><div>I can't seem to catch "foreign" exception or any exception using the following pseudo code:</div><div><br></div><div>try {</div><div>// cast function ptr and execute</div><div>   ir_func();</div><div>} catch (const myEx&) {</div><div>} catch (...) {</div><div>}</div><div><br></div><div>Looking at:</div><div><dt></dt><dt><font color="#000000" face="Lucida Grande, Lucida Sans Unicode, Geneva, Verdana, sans-serif"><span style="font-size:14px;line-height:21px"><b>LLVM_ENABLE_EH:BOOL</b></span></font></dt><dt><font color="#000000" face="Lucida Grande, Lucida Sans Unicode, Geneva, Verdana, sans-serif"><span style="font-size:14px;line-height:21px">Build LLVM with exception-handling support. This is necessary if you wish to link against LLVM libraries and make use of C++ exceptions in your own code that need to propagate through LLVM code. Defaults to OFF.</span></font></dt><dt><br></dt><dt>It seems to be exactly what I require. <br></dt><dt><br></dt></div><div>I enabled <span style="color:rgb(106,106,106);font-weight:bold;line-height:18.2px">LLVM_ENABLE_EH </span><span style="color:rgb(106,106,106);line-height:18.2px">and </span><span style="color:rgb(106,106,106);font-weight:bold;line-height:18.2px">LLVM_ENABLE_RTTI </span>but it doesn't seems to work.</div><div>I also tested it with /EHs /EHsc in msvc. It makes no difference</div><div><br></div><div>I also looked at the ExceptionDemo.cpp, but it seems to be unsupported under windows. Do I need to try catch and retrhow in my ir_func() ? </div><div><br></div><div>Regards,</div><div><br></div></div>
<br></div></div>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>