Not using C++ exceptions by design, in llvm/clang

zaharpopov picture zaharpopov · Nov 2, 2010 · Viewed 9.1k times · Source

llvm/clang are considered good C++ code bases. I wonder why C++ exceptions arenot used in them at all?

Memory is managed using something like pools, and erros are reported with returnd values and codes like in C. They even wrapping operator new to be placement new that returns error and not exception when no memory.

Do you have idea why llvm philosophy is not to use C++ exceptions when most books recommend using them?

Answer

ohmantics picture ohmantics · Dec 1, 2010

Chris Lattner recently clarified this issue in the LLVM project coding standards.

Not using exceptions and RTTI reduces executable size and reduces overhead. (You might argue that zero-cost exceptions have no overhead unless thrown. At a minimum, they actually break up the code into smaller basic blocks and inhibit some types of code motion.)