[Cfp-interest] Fwd: (SC22WG14.13396) What syntax should be used to express IEEE 754-2008 alternate exception handling in C?

David Hough CFP pcfp at oakapple.net
Tue Aug 5 15:00:17 PDT 2014


> > I haven't been following this discussion closely enough, but wanted to =
> express some vague uneasiness about adding another exception handling =
> mechanism to C.  We already have Posix thread cancellation, and some =
> code has to deal with C++ exceptions.  Correct programs in theory have =
> to deal with all of these by providing clean-up actions that are =
> compatible with any kind of exception that might pass through a =
> particular function frame.  Having to deal with more than one kind of =
> exception seems somewhere between ugly and intractable.
> >=20
> > In my opinion, Posix thread cancellation is broken enough that I would =
> love to see it replaced by something that looks more like C++ =
> exceptions.  But that opinion is not universally shared, and the Posix =
> folks seem quit attached to it.

Thread cancellation is quite a bit more heavy weight than anything we
have in mind, which is all within a single thread.

Alternate exception handling is one kind
of attribute, another is static rounding directions. Some forms of alternate
exception handling involve change in control flow, others do not.
There is a certain partial congruence between the change-in-control-flow
style of alternate exception handling and the try/catch mechanisms in
many modern languages.      However the congruence doesn't seem to be
strong enough to overcome the prejudice against try/catch in C, so I think
we will abandon that try/catch syntactic approach and try to find some way of
attaching attributes to compound statements - and may end up with #pragma
if that generates the least resistance.

The cleanup aspect is that 

{
#pragma STDC xyz
code
}

is that the special treatment specified by xyz has to be undone and the
previous treatment restored when you exit the compound statement, no matter how
you exit.   This issue is independent of syntax.


More information about the Cfp-interest mailing list