[Cfp-interest] draft of syntax discussion for C committee

David Hough CFP pcfp at oakapple.net
Tue Jun 10 15:18:53 PDT 2014


> Although arguably not as convenient as what we are discussing right now, 
> can we not add in new macros as we are already discussing for the floating 
> point exceptions, and 

> can we not... use the existing feclearexcept, fegetexceptflag, 
> feraiseexcept, fesetexceptflag, and fetestexcept functions? 

The names are a bit confusing, but as far as I can tell, 
feclearexcept, fegetexceptflag, fesetexceptflag, fetestexcept
act upon flags rather than exceptions... that's an important
distinction for underflow.

feraiseexcept does something different from fesetexceptflag,
but I don't see how to apply it to the present problem.

In any case, I'd suggest coding a couple of examples, namely
the continued fraction case and the root-sum-squares loop, to see how
they'd look.     I'm not as worried about the compiler recognizing what's
going on as a programmer not being able to decipher somebody else's code.

> The disadvantages are that it is not as "clean" as the C++ style exception 
> handling, it may make it harder for optimizing compilers to recognize the 
> exception pattern (though I would argue it is actually easier on the 
> compiler and hardware with the current C standard way), and in a 
> non-optimizing case, may be much slower on some hardware.

The main issues are

1) performance in the normal case
2) portability of source code
3) correctness of the exceptional case
4) performance in the exceptional case (mainly not getting into long or
   infinite loops because of deferred exception detection)


More information about the Cfp-interest mailing list