|
Boost : |
From: Holger Grund (yahoo_at_[hidden])
Date: 2003-09-21 20:13:40
[REREPOST:There should be more than just one paragraph ]
Carlos,
> > No, I'm disabling the warning with pragmas. The technique works fine.
>
> I don't think so. Well, it can fail. See Carl Daniel post on 9/21. I saw
> the thread(s) on comp.lang.c++.moderated about the subject but nobody
> mentioned the interaction of the *technique* with /EHs at that time.
>
It's probably a good idea to post in the Microsoft newsgroups
for specific compiler issues.
FWIW, when David pointed me to his article (thanks again David)
I came to same the same conclusion myself (that is, that /EHa
is _not_ required for this technique).
The optimizer requires /EHa to know that it must not elide
unwinding information. That is only important if unwinding
actually takes place.
Consider the following example
extern "C" void crash_me();
void foo(){ std::cout << "foo" << std::endl; }
struct X{~X(){ foo(); } };
void some_func()
{
X x;
crash_me();
}
With /EHsc the compiler assumes that crash_me does _not_ cause
a C++ exception to be thrown. Hence it can elide the unwinding
information. The generated code would conceptually be
equivalent to:
void some_func()
{
crash_me(); foo();
}
Now if crash_me raises a structured exception and
the SE translator throws a C++ exception, unwinding
procedes from some_func. Since the unwinding information
for x has been removed, foo() will never be called in that
case.
So in general when you want unwinding do use /EHa.
But David's suggested method is just about preventing
unwinding. I do not see any problem with /EHsc
and _set_se_translator in this case (not that it matters).
-hg
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk