[Cfp-interest] order of declaration in C

David Hough CFP pcfp at oakapple.net
Fri May 30 14:34:54 PDT 2014


One of the possible problems of try/catch is that
the list of floating-point exceptions to be caught comes after the 
code that must be compiled knowing about them.   So that implies some sort
of lookahead to see what catches follow a try block before compiling it.
Note that if catches are to be implemented with traps, the trap enables
could be embodied in preamble and postambles 
that are compiled after the try and
catches are compiled, but executed before and after the try.    However
if the catches are to be implemented by checking flags within the try block, 
those flag checks should be inserted in the code for the try block.
If the flag checkes are implemented at the end of the try block, then
it becomes a preamble/postamble situation again.    However we really
want to encourage compilers to detect exceptions as soon as possible
because continuing execution with a bunch of NaNs or subnormals might
get very expensive - only to be thrown away anyway.

My question is:   is there anything else in C that requires such lookahead
in order to generate code?
Is this a big enough deal to worry about?

Ian proposes declaring the exceptions of interest in advance, but I figure
if you're going to do that, you might as well declare the exception
handling in advance too, so it's all in one place.     Maybe something like

Instead of conventional,

try {
normal code
}
catch_fe(e, elist) {
exceptional code
}

suppose the syntax for catch_fe is more like:

try {
catch_fe(e, elist) {
exceptional code
}
normal code
}

I'm sure that will bother anybody used to conventional try/catch.




More information about the Cfp-interest mailing list