Catching C++ Exceptions in D

Elie Morisse via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 5 14:58:09 PST 2016


On Tuesday, 5 January 2016 at 20:07:11 UTC, Walter Bright wrote:
> On 1/5/2016 10:51 AM, Elie Morisse wrote:
>> why not distinguish C++ exceptions from D ones in the 
>> personality routine?
>
> How?

Are you aware of 
https://syniurgeblog.wordpress.com/2015/11/20/calypso-catching-cpp-exceptions-in-d/?

For DMD if the personality functions sees the C++ exception class 
(3rd arg passed to the personality func) would it be hard to make 
it look for C++ catch clauses?

With Calypso those catch clauses are std::type_info pointers 
wrapped inside a D class so that cast() is used to differentiate 
D catch clauses from C++ ones in the action table, and the 
personality function match those std::type_info against the one 
from the C++ exception header by calling the virtual function 
type_info::__do_catch(type_info*).

A single personality routine handles both D and C++ exceptions, 
and I don't think having a different one for C++ exceptions would 
make things much easier. The tricky part for DMD is probably the 
std::type_info generation.


More information about the Digitalmars-d mailing list