When Firefox is built with GCC, the
-fno-exceptions option is used, which means that exception-handling is disabled. I’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. This means, for example, that the vanilla
operator new will throw an exception if it fails, because it’s in libstdc++.so, but Firefox code cannot catch the exception, because
-fno-exceptions is specified. (If you write a try-block, GCC will give you an error.)
This has important consequences: if you compile your application with
-fno-exceptions, you cannot use any standard library functions that might throw exceptions. SpiderMonkey’s C++ coding standard is succinct, perhaps overly so: “No exceptions, so std is hard to use.”
Another fine example of the “so you think you’ll be able to use a subset of C++, eh?” fallacy. See bug 624878 for a specific manifestation of this problem. I wonder if there are others case like that in Firefox.