druntime posix .. nothrow!

Marco Leise Marco.Leise at gmx.de
Wed Apr 9 23:51:49 PDT 2014


Am Wed, 09 Apr 2014 22:19:30 -0700
schrieb Brad Roberts <braddr at puremagic.com>:

> On 4/9/14, 9:49 PM, Etienne Cimon wrote:
> > On 2014-04-10 00:01, Brad Roberts wrote:
> >> And you aren't submitting a pull request with those changes because...
> >
> > Well, I was hoping for someone to catch on with the extern(C) = nothrow idea. Maybe this reallyy
> > belongs in DMD!
> 
> It shouldn't, because it's not 100% true, even for libc related functions.  Consider qsort and it's 
> function pointer parameter.  There's other examples of the same.  Just because most are no through 
> doesn't imply they all are.

Well, the intention was good. If I may add: Don't pass a D
function that throws to C/C++ code on Linux/GNU x86_64.
DMD's stack unwinder relies on how the D compiler writes
stack frames. In particular it expects frame pointers, which
aren't used by default on that arch. As a result druntime will
terminate your application.

> Leave the realm of libc and it's even less true.  Consider all the C 
> wrappers for c++ libraries.  It's perfectly legal for any of those to throw.

Isn't that paradox? Why is it legal to throw C++ exceptions
into a language that can't possibly look at them? Does that
mean every language  which interfaces with C handles
C++ exceptions in some way? E.g. JNI, Python, ...?

I mean, to be legal it has to be defined to do something
specific, other than killing your program on the spot.

-- 
Marco



More information about the Digitalmars-d mailing list