Use C++ exception model in D

deadalnix deadalnix at gmail.com
Thu Apr 10 15:05:21 PDT 2014


On Thursday, 10 April 2014 at 19:23:12 UTC, Jacob Carlborg wrote:
> On 2014-04-10 08:53, deadalnix wrote:
>
>> The C++ personality function from GCC does not catch, but do 
>> the cleanup
>> on foreign exceptions. That sound like the right behavior to 
>> me.
>
> As far as I understand the cleaning is only a part of what 
> personality function does. The first thing it does is check if 
> the thrown exception can be handled. Like determine if it's a 
> C++ exception or some other exception. If I recall correctly, 
> it also determines if and where to resume unwinding, where to 
> find catch blocks and so on.
>
> This [1] series of blog posts gives a pretty good understanding 
> of how C++ exceptions work under the hood, for those that don't 
> want to read the ABI documentation.
>
> [1] 
> http://monoinfinito.wordpress.com/series/exception-handling-in-c/

You want to look at libstdc++-v3/libsupc++/eh_personality.cc in 
gcc's source code.

The personality function test if the exception is a C++ 
exception, in which case the regular flow apply. If not, the 
foreign_exception flag is set, and some behavior are altered. 
Basically, for what we are concerned with D, only cleanup will be 
executed (the filter part is irrelevant to D).


More information about the Digitalmars-d mailing list