|
Boost : |
Subject: Re: [boost] expected/result/etc
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2016-02-12 18:56:38
On Thu, Feb 11, 2016 at 6:36 PM, Gavin Lambert <gavinl_at_[hidden]>
wrote:
> On 12/02/2016 14:27, Emil Dotchevski wrote:
>
>> It's criminal that MSVC can translate OS exceptions into C++ exceptions.
>>>> :)
>>>> It's not that it's broken on other OSes, other compilers don't do this
>>>> because it's wrong. I do not recommend turning that MSVC option on.
>>>>
>>>> It's not an option. That's just what it does.
>>>
>>
>> Not true, it's an option. They call it "structural exception handling".
>>
>
> As I mentioned, as far as I am aware that just disables the ability to
> catch such exceptions (in part, by only inserting the logic for unwinding
> in places that it expects C++ exceptions). I don't think it stops the
> compiler transporting exceptions that way. I could be wrong about that
> though.
>
The __try/__except and __try/__finally statements are C (not C++)
extensions of MSVC. See
https://msdn.microsoft.com/en-us/library/swezty51.aspx.
Optionally the C++ compiler can generate code that treats these exceptions
as C++ exceptions. Microsoft does not recommend using that option, as
indicated by the first paragraph from the linked article:
"Although Windows and Visual C++ support structured exception handling
(SEH), we recommend that you use ISO-standard C++ exception handling
because it makes code more portable and flexible."
So, don't enable this behavior, it leads to too much overhead and has
nothing to do with how C++ exceptions are supposed to work.
Emil
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk