{"id":492,"date":"2011-01-18T14:33:41","date_gmt":"2011-01-18T03:33:41","guid":{"rendered":"http:\/\/blog.mozilla.org\/nnethercote\/?p=492"},"modified":"2011-01-18T14:35:11","modified_gmt":"2011-01-18T03:35:11","slug":"the-dangers-of-fno-exceptions","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/nnethercote\/2011\/01\/18\/the-dangers-of-fno-exceptions\/","title":{"rendered":"The dangers of <code>-fno-exceptions<\/code>"},"content":{"rendered":"<p>When Firefox is built with GCC, the <code>-fno-exceptions<\/code> option is used, which means that exception-handling is disabled.\u00a0 I&#8217;ve been told that this is because the performance of code that uses exceptions is unacceptable.<\/p>\n<p>Sounds simple, until you realize that libraries such as libstdc++.so are <strong>not<\/strong> built with this option.\u00a0 This means, for example, that the vanilla <code>operator new<\/code> will throw an exception if it fails, because it&#8217;s in libstdc++.so, but Firefox code <strong>cannot<\/strong> catch the exception, because <code>-fno-exceptions<\/code> is specified.\u00a0 (If you write a try-block, GCC will give you an error.)<\/p>\n<p>This has important consequences:\u00a0 <strong>if you compile your  application with <code>-fno-exceptions<\/code>, you cannot use any standard library functions that might throw exceptions<\/strong>.\u00a0 <a href=\"https:\/\/wiki.mozilla.org\/JavaScript:SpiderMonkey:C%2B%2B_Coding_Style\">SpiderMonkey&#8217;s C++ coding standard<\/a> is succinct, perhaps overly so: &#8220;No exceptions, so std is hard to use.&#8221;<\/p>\n<p>Another fine example of the &#8220;so you think you&#8217;ll be able to use a subset of C++, eh?&#8221; fallacy.\u00a0 See <a href=\"https:\/\/bugzilla.mozilla.org\/show_bug.cgi?id=624878\">bug 624878<\/a> for a specific manifestation of this problem.\u00a0 I wonder if there are others case like that in Firefox.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When Firefox is built with GCC, the -fno-exceptions option is used, which means that exception-handling is disabled.\u00a0 I&#8217;ve been told that this is because the performance of code that uses exceptions is unacceptable. Sounds simple, until you realize that libraries such as libstdc++.so are not built with this option.\u00a0 This means, for example, that the [&hellip;]<\/p>\n","protected":false},"author":139,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[616,30],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/492"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/users\/139"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/comments?post=492"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/492\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/media?parent=492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/categories?post=492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/tags?post=492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}