Folgen der Verwendung der strukturierten Ausnahmebehandlung (SEH)?
-
15-11-2019 - |
Frage
Ich sehe Doug Harrison hat eine gute Erklärung gemacht, was mit der Verwendung (dh fangenden) strukturierten Ausnahmen "falsch" ist (siehe Frage # 3 ).Aber welche anderen Konsequenzen gibt es?Was passiert zum Beispiel, wenn ich mehrere Projekte mit / EHA zusammenstellen, mit anderen Projekten mit / EHS gemischt?Gibt es Probleme, wenn die Bibliotheken miteinander verknüpft sind (Kompilierzeit oder Laufzeit)?
aber das ist nur ein Beispiel.Welche anderen Probleme könnten es geben?
Lösung
/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.