On Sunday, 29 December 2013 at 14:50:52 UTC, H. S. Teoh wrote:
Yes, since C code will not throw D exceptions (C doesn't know
anything
about D exceptions). Unless you pass in a function pointer to a
D
function that does throw an exception... but that case doesn't
work for
other reasons, so it generally shouldn't be done. So, barring
that, all
C code is automatically nothrow.
Some C libraries are designed to support long-jumping or
throwing[1] out of some of their callbacks (when they are, it
will be explicitly stated in the documentation). These callbacks
need not necessarily be marked nothrow. Of course, the C function
that calls the callback should have the same throwness as the
callback - if one is marked as nothrow, both should be, and vice
versa.
Interestingly, D programs that catch non-Exception's and try to
return to a normal path of code execution will be extra prone to
spectacular failure if they use C libraries with callbacks that
don't support long-jumping out of them, which is most...
[1] Whether stack-unwinding will work is dependent on the
exception mechanism and sometimes compilation flags etc.