<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>Hello,</div><div><br></div><div>While running the following code, it crashes due to an invalid free operation:</div><div><br></div><div><div>exc(8657) malloc: *** error for object 0x7f97c14039e0: pointer being freed was not allocated</div><div>*** set a breakpoint in malloc_error_break to debug</div><div>fish: Job 1, './exc' terminated by signal SIGABRT (Abort)</div></div><div><br></div><div>--- --- --- --- --- </div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(120, 73, 42); ">#include <span style="color: #d12f1b"><string></span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; "><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "><span style="color: #bb2ca2">class</span> Error {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(187, 44, 162); ">public<span style="color: #000000">:</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> <span style="color: #bb2ca2">explicit</span> <span style="color: #bb2ca2">inline</span> Error(<span style="color: #bb2ca2">const</span> std::string &str) noexcept {}</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">};</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; "><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">std::string _cxx_strfmt() noexcept { <span style="color: #bb2ca2">return</span> std::string(); }</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; "><br></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "><span style="color: #bb2ca2">int</span> main(<span style="color: #bb2ca2">int</span> argc, <span style="color: #bb2ca2">char</span> **argv) {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> <span style="color: #bb2ca2">try</span> {</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> <span style="color: #bb2ca2">throw</span> Error(_cxx_strfmt());</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; "> } <span style="color: #bb2ca2">catch</span> (...) {}</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">}</div></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">------</div><div><br></div><div>compiled using </div><div>clang++ -std=c++11 exc.cpp</div><div><br></div><div>I can't see what is wrong with this code, but if I remove the <span style="font-family: Menlo; font-size: 11px; ">noexcept </span><span style="background-color: transparent;">declaration (either one), it stop crashing and run as expected.</span></div><div><span style="background-color: transparent;"><br></span></div><div>Is this something I'm doing wrong, or this is a subtle clang bug ? </div><div><br></div><div>I attach the llvm ir generate with noexcept (exc-crash.s) and the one without (exc.s)</div><div><br></div><div>If this is a bug in clang, tell me, I will fill a report.</div><div><br></div><div>Thanks</div><div><br></div><div>
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px; "><div>-- Jean-Daniel</div><div><br></div><div><br></div></span><br class="Apple-interchange-newline">
</div>
</body></html>