checking for overflow in C

Doug Gwyn gwyn at smoke.BRL.MIL
Sun May 14 10:43:46 AEST 1989


In article <1989May12.154417.21344 at utzoo.uucp> henry at utzoo.uucp (Henry Spencer) writes:
>SIGFPE and friends unfortunately are *very* machine-specific, because you
>get signals only when the hardware feels like supplying them.

There is indeed a wide variety of arithmetic exception behavior.  Some
systems generate different exceptions for integer vs. floating overflow,
some generate the same exception, some generate exceptions in one case
but not the other, some generate exceptions only for limited classes of
arithmetic "problems", etc.

A few years ago, a system manager here, responding to naive "customer"
pressure to generate floating exceptions on our Gould PN series machines,
modified the run-time start-off module to enable exceptions.  What he
didn't appreciate was that the C compiler generated code that required
integer overflow to be ignored, and the Gould hardware tied integer
and floating exceptions to the same enable bit.  Consequently non-floating
applications started dying due to unexpected SIGFPEs.  We were not amused.



More information about the Comp.lang.c mailing list