www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Request for Information: Exceptions interop

reply Richard (Rikki) Andrew Cattermole <richard cattermole.co.nz> writes:
After some talking with Manu, I have a question that will feed 
into some thinking regarding exceptions.

For each compiler dmd/ldc/gdc, for each target (win32, win64, 
linux, osx, ext.), are the unwinding tables compatible with the 
C++/Objective-c used ones for that target?

What I need to know is:
- Will the D unwind cleanup hook be called by C++?
- Will the C++ unwind cleanup hook be called by D?

What I mean by unwind cleanup hook is things like destructors and 
finally statements.
Apr 07
next sibling parent reply Salih Dincer <salihdb hotmail.com> writes:
On Monday, 7 April 2025 at 08:47:15 UTC, Richard (Rikki) Andrew 
Cattermole wrote:
 ...
 For each compiler dmd/ldc/gdc, for each target (win32, win64, 
 linux, osx, ext.), are the unwinding tables compatible with the 
 C++/Objective-c used ones for that target?
 ...
Interoperability between D and C++ exception handling mechanisms is limited and not inherently supported. Therefore, exceptions thrown in one language may not be properly caught or handled by the other. https://forum.dlang.org/post/mailman.71.1397054005.1648.digitalmars-d puremagic.com Have you seen this very old thread? SDB 79
Apr 07
parent reply "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
On 08/04/2025 8:36 AM, Salih Dincer wrote:
 On Monday, 7 April 2025 at 08:47:15 UTC, Richard (Rikki) Andrew 
 Cattermole wrote:
 ...
 For each compiler dmd/ldc/gdc, for each target (win32, win64, linux, 
 osx, ext.), are the unwinding tables compatible with the C++/ 
 Objective-c used ones for that target?
 ...
Interoperability between D and C++ exception handling mechanisms is limited and not inherently supported. Therefore, exceptions thrown in one language may not be properly caught or handled by the other.
I'm not interested in throwing or catching, just what happens when one is thrown, is the cleanup functions get called as exceptions bubble up?
 https://forum.dlang.org/post/mailman.71.1397054005.1648.digitalmars- 
 d puremagic.com
 
 Have you seen this very old thread?
 
 SDB 79
A long time ago likely, however I know work has happened since then so I'm wanting an up to date status of it.
Apr 07
parent Salih Dincer <salihdb hotmail.com> writes:
On Monday, 7 April 2025 at 20:48:06 UTC, Richard (Rikki) Andrew 
Cattermole wrote:
 ... I'm wanting an up to date status of it.
Look: https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Improved%20__attribute__%28%28cleanup%29%29%20Through%20defer.html Published Proposal, 2025-03-18 and: https://www.llvm.org/docs/ExceptionHandling.html SDB 79
Apr 07
prev sibling parent "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
Asked at monthly meeting.

It mostly will work, however it is implementation defined.
Apr 11