[Cfp-interest] more on try/catch

David Hough CFP pcfp at oakapple.net
Thu May 29 13:37:10 PDT 2014


Unlike normal C++ try blocks which can be compiled without reference to
whatever exceptions might be caught, floating-point try blocks have to
be compiled knowing what exceptions might be singled out for special
treatment.

So maybe fp try/catch
should just be separated syntactically as
well as semantically from C++:


fe_try {
}
fe_catch_sub( e, elist) {
}
fe_catch_exceps( e, elist) {
}
fe_catch_flags( f, flist) {
}

I've added a new wrinkle - fe_catch_sub which computes a substituted
value and continues execution.     How is the substituted value evaluated?
It's the value of a compound statement - but it's undefined (and compilers
ought to warn) if it uses any variables whose values change within the
try block.      Thus the try block to use with the substituted value
is probably pretty small.     The substituted value can be presubstituted
if there's system support for that, but in the much more likely event that
there isn't, then the compiler has to generate appropriate tests and branches.
The elist usually better be a list of one subexception of invalid
rather than invalid itself;
otherwise the compiler has to generate tests wherever a signaling NaN might
cause an invalid exception.     Do we need a nonstandard pragma (meaning
OK to ignore) that says compiler need not worry about signaling NaNs in a
given scope?     Life would have been a lot simpler if signaling NaNs had
been given their own exception in 1977.
 
The substitute-exor feature of 754-2008 can be provided by the above plus
a standard function fe_exor_result(x,y,z) which returns abs(x) with the
exor signs of y and z.



More information about the Cfp-interest mailing list