ollo ollo - 1 month ago 4x
C++ Question

Using -fno-unwind-tables in conjunction with -fno-exceptions

What is the benefit of using

in addtion to
– especially on a (freestanding) C++ Embedded Systems?

According to Practical Guide to Bare Metal C++ — § Exceptions there should be both used:

It is possible to forbid usage of throw statements by providing certain options to the compiler. For GNU compiler (gcc) please use
in conjunction with

However there's no explanation what
acutally does.


Per the GCC documentation, it suppresses the generation of static unwind tables (as opposed to complete exception-handling code), the main benefit of which is likely to be smaller object files due to not containing that data. Note that such tables might be used for things like stack-walking code for backtrace generation even in the absence of full-blown exception-handling (e.g. in C code).

I don't know for sure, but I'd imagine that in the case where, by default, full exception-handling code is already disabled but static unwind tables are enabled, -fno-exceptions probably doesn't affect the latter, hence using both options covers all bases. In other words, the compiler may want to generate one or the other, but when size and efficiency matter you definitely want it to do neither.