<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="EN-IE" link="blue" vlink="purple"><p class="MsoNormal"><span style="font-family:'Book Antiqua',serif;color:rgb(31,73,125)">Since an implementation that does not support Exception Handling cannot by definition be ISO C++ compliant, a reasonable compromise to calling ‘</span><span style="font-family:'Courier New';color:black">abort</span><span style="font-family:'Book Antiqua',serif;color:rgb(31,73,125)">’ might be to call ‘</span><span style="font-family:'Courier New';color:black">terminate</span><span style="font-family:'Book Antiqua',serif;color:rgb(31,73,125)">’ wherever a ‘</span><span style="font-family:'Courier New';color:black">throw</span><span style="font-family:'Book Antiqua',serif;color:rgb(31,73,125)">’ is expected from the Standard library.  Since a program that does not support exception handling cannot have any ‘</span><span style="font-family:'Courier New';color:black">catch</span><span style="font-family:'Book Antiqua',serif;color:rgb(31,73,125)">’ clauses, calling ‘</span><span style="font-family:'Courier New';color:black">terminate</span><span style="font-family:'Book Antiqua',serif;color:rgb(31,73,125)">’ would in effect have the same semantic effect as a ‘</span><span style="font-family:'Courier New';color:black">throw</span><span style="font-family:'Book Antiqua',serif;color:rgb(31,73,125)">’ where no ‘</span><span style="font-family:'Courier New';color:black">catch</span><span style="font-family:'Book Antiqua',serif;color:rgb(31,73,125)">’ exists.  This would also allow the programmer to use ‘</span><span style="font-family:'Courier New';color:black">set_terminate</span><span style="font-family:'Book Antiqua',serif;color:rgb(31,73,125)">’ in an approximation to the Standard.  If this not set, it will default to ‘</span><span style="font-family:'Courier New';color:black">abort</span><span style="font-family:'Book Antiqua',serif;color:rgb(31,73,125)">’ anyway.</span></p></div></blockquote><div><br></div><div>Note that terminate() is defined in <exception> header. I'd rather avoid that header when using the -fno-exceptions library variant. But I think this is not a problem, a competent linker would still be able to throw away the unused exception handling machinery even when the <exception> header is included (the library itself will have to be compiled with -ffunction-sections and -fdata-sections).</div><div><br></div><div>At any rate, current proposal [1] allows the default abort-if-no-exceptions behaviour to be overridden.</div><div><br></div><div>Best,</div><div><br></div><div>- Asiri</div><div><br></div><div>[1] <a href="http://reviews.llvm.org/D14653">http://reviews.llvm.org/D14653</a></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="EN-IE" link="blue" vlink="purple"><p class="MsoNormal"><span style="font-family:'Book Antiqua',serif;color:rgb(31,73,125)"><u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:'Book Antiqua',serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:'Book Antiqua',serif;color:rgb(31,73,125)">Certainly the need for a good C++ library for embedded systems is essential, and unfortunately the impact of EH keeps a lot of programmers using C instead.  For our implementation I build the libraries with EH disabled, though I do keep RTTI enabled.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:'Book Antiqua',serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:'Book Antiqua',serif;color:rgb(31,73,125)">All the best,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:'Book Antiqua',serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:'Book Antiqua',serif;color:rgb(31,73,125)">            MartinO<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:'Book Antiqua',serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><b><span lang="EN-US" style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span lang="EN-US" style="font-size:10pt;font-family:Tahoma,sans-serif"> cfe-dev [mailto:<a href="mailto:cfe-dev-bounces@lists.llvm.org" target="_blank">cfe-dev-bounces@lists.llvm.org</a>] <b>On Behalf Of </b>Asiri Rathnayake via cfe-dev<br><b>Sent:</b> 28 November 2015 21:20<br><b>To:</b> Eric Lasota<br><b>Cc:</b> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br><b>Subject:</b> Re: [cfe-dev] [RFC][libcxx] Fix and maintain the no-exceptions build of libcxx<u></u><u></u></span></p><div><div class="h5"><p class="MsoNormal"><u></u> <u></u></p><div><div><p class="MsoNormal">Hi Eric,<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p><div><blockquote style="border-style:none none none solid;border-left-color:rgb(204,204,204);border-left-width:1pt;padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm"><div><div><p class="MsoNormal"><u></u> <u></u></p></div><p class="MsoNormal">If you're going to change exceptional cases to call abort though, then it'd be good to make other cases to be consistent with that approach, like vector's __throw_length_error and __throw_out_of_range, regex's __throw_regex_error, and possibly others.<u></u><u></u></p></div></blockquote><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">The initial patch [1] only proposes the framework for fixing the tests and updating the library sources. I kept it minimal to make the review easier. I have a giant local patch that fixes the rest of the tests (removes the XFAILS) and the remaining library sources. And yes, vector's __throw_length_error, __throw_out_of_range and regex's __throw_regex_error are all updated in it (and many other places).<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">I'm still waiting for the approval of this initial patch so that I can upstream the rest.<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Best,<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">- Asiri<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">[1] <a href="http://reviews.llvm.org/D14653" target="_blank">http://reviews.llvm.org/D14653</a> <u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><blockquote style="border-style:none none none solid;border-left-color:rgb(204,204,204);border-left-width:1pt;padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm"><div><div><div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">On Fri, Nov 27, 2015 at 7:03 AM, Asiri Rathnayake <<a href="mailto:asiri.rathnayake@gmail.com" target="_blank">asiri.rathnayake@gmail.com</a>> wrote:<u></u><u></u></p><div><p class="MsoNormal">Hello,<u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Asserts getting optimized away is a problem, as then an exceptional code path will simply ignore the error and continue. Of course, one can argue that an exceptional state in a no-exceptions library is something that is OK to be ignored.<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">In my latest patch [1], the user has the option to override the default abort behaviour by providing a custom __libcxx_noexceptions_abort() function. I think with this mechanism you can achieve the old behaviour if desired.<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Cheers,<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">- Asiri<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">[1] <a href="http://reviews.llvm.org/D14653" target="_blank">http://reviews.llvm.org/D14653</a><u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div></div><div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">On Thu, Nov 26, 2015 at 5:00 PM, via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<u></u><u></u></p><div><div><div><p class="MsoNormal"><span style="font-family:Calibri,sans-serif">Wouldn’t the better thing to do be to assert rather than call abort (like vector’s exceptions already do, for instance)?  One important use case of no-exception builds is to completely optimize out throwing paths and the checks leading to them, which wouldn’t happen if the exceptional path called abort.<u></u><u></u></span></p></div></div></div><p class="MsoNormal" style="margin-bottom:12pt"><br>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><u></u><u></u></p></div><p class="MsoNormal"><u></u> <u></u></p></div></div><p class="MsoNormal"><u></u> <u></u></p></div></div></div></blockquote></div><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div></div></blockquote></div><br></div></div>