Question

I see Doug Harrison has made a good statement of what is "wrong" with using (i.e. catching) structured exceptions (see question #3). But what other consequences are there? For example, what happens if I have several projects compiled with /eha, mixed with other projects compiled with /ehs? Are there issues when the libraries are linked (compile time or run-time) with eachother?

But that is just one example. What other issues might there be?

Was it helpful?

Solution

/EHa disables an optimization. With /EHs in effect, the compiler can omit exception filters if it can be sure that no C++ exception is ever thrown by the code wrapped in a try {}. That's a small space optimization on x86 and x64, very small time optimization on x86. Problem is, those filters are needed if you catch non-C++ exceptions. The consequence is that the stack gets unwound when such an exception is caught without the destructor of a C++ object getting called. Not good, /EHa avoids it.

Mixing doesn't cause linker problems. It causes the above problem.

Yes, /EHa also makes catch(...) do a very stupid thing, it really catches everything. That ship wreck sailed a while ago though, Pokemon C++ exception handling is a bad idea too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top