Boost logo

Boost :

From: Carl Daniel (cpdaniel_at_[hidden])
Date: 2004-10-28 00:07:50


Pavel Vozenilek wrote:
> "Stefan Seefeld" wrote:
>
>> I'v recently run into a problem with 'catch(...)'
>> on MSVC 7.1, where a segmentation fault resulted
>> in a 'first-class exception' (!) that was caught
>> by 'catch(...)' even though the stack wasn't
>> unwound.
> ...
>> I'd like to get your feedback on how to
>> use it portably. Are my findings false?
>>
> No, it is behavior of MSVC by default.
>
> This compiler has switch not to map
> Win32 exceptions into C++ ones.

VC++ never maps platform exceptions into C++ exceptions unless you
specifically write code to do it (using __set_se_handler).

What it does do is catch platform exceptions with catch(...). This is
generally acknowledged to be A Bad Thing, unfortunately there's no way you
can make catch(...) not catch platform exceptions with VC7.1. Using VC7.1
it's only "safe" to catch platform exceptions if you compile with /EHa (the
default is /GX which is equivalent to /EHsc). Under VC8 catch(...) will not
catch platform exceptions in code compiled with /EHs, while code compiled
with /EHa will retain the behavior it has now.

If you want to use catch(...) in VC++ code and NOT translate platform
exceptions into C++ exceptions, your only real choice is to use
__set_se_handler to set a "handler" that terminates the program when a
platform exception is raised.

-cd


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk