tags:

views:

139

answers:

2

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) ?

+7  A: 

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 http://stackoverflow.com/questions/691168/how-much-footprint-does-c-exception-handling-add.

anon
+3  A: 

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.

Jerry Coffin
OTOH, working set size does have a speed impact. But I agree that, in the end, only measuring will show. __The usual disclaimer to all optimization questions:__ _Your choice of algorithms and their implementations have much more impact than such issues._
sbi
@sbi:while you're right, the extra code *can* be (though it's isn't always) segregated, so as long as there's no exception thrown, it just sits on the disk with little effect on the working set size.
Jerry Coffin
@Jerry: Yes, that could be. Or it could be different. Hence my support for the advice to measure.
sbi