Re: EH & Optimization
Staffan Langin wrote:
Hello,
I have a question pertaining optimizition and exception handling. It
seems that the compiler (VS 2005) doesn't emit a SEH prolog/epilog
when constructing/destructing objects with an empty exception
specification (throw()). That's fine and the behavior I expect/want.
However, when constructing/destructing an array of the same
object-type the compiler seems to emit a SEH prolog/epilog for each
array. The overhead is quite significant, about 60 instructions for
each object, especially when the constructor/destructor in a release
build is inlined and performs no operation ie should compile to a
no-op. So my question: How do I configure the compiler to not emit a
SEH prolog/epilog when constructing/destructing array-members with an
empty exception specification?
Short answer: you can't.
There's no option to force the compiler to omit exception frames - in cases
that the compiler understands, it will omit the exception frame in optimized
builds. Apparently yours is not one of those cases.
One thing I'd do is remove all of the exception specifications to see if
that makes any difference. While VC++ parses exception specifications, it
doesn't really support them. In fact, in most cases, they're completely
ignored. The one exception, pardon the pun, is that a specification of
throw() is treated as equivalent to __declspec(nothrow), which is actually
the diametric opposite of what the C++ standard says it means.
BTW: I'm using the /EHsc compiler option.
You could try changing to /EHa, but generally that will only decrease the
compiler's ability to omit exception frames, so it's not likely to help your
situation.
-cd