leeeroy
leeeroy

Reputation: 11446

g++, cost of exceptions when I don't use exceptions

I've some C++ projects, which does not use exception handling.

What are the benefits of adding -fno-exceptions , or does gcc figure out itself that I don't use exceptions(nor any libraries that uses exceptions) ?

Upvotes: 2

Views: 728

Answers (2)

Jerry Coffin
Jerry Coffin

Reputation: 490118

The main difference is likely to be more in the size of the generated code than the speed of execution. You can obviously test it out to see what difference it makes, but if your interest is primarily in execution speed it probably won't make enough difference to notice or care about.

Upvotes: 3

anon
anon

Reputation:

Probably minimal - the cost of an exception is mostly incurred if an exception is actually thrown. However, as usual the answer is to try it out and time it, which in this case would seem to be trivially easy. There are quite afew existing questions on this subject, such as How much footprint does C++ exception handling add.

Upvotes: 7

Related Questions