critical impact:
SIGFPE - floating-point exception differences (CrCh339)
Problem description
The default handling mode of floating-point exceptions is different on Tru64 UNIX and HP-UX.
By default, Tru64 UNIX enables traps for invalid operation, division by zero, and overflow exceptions, and disables traps for underflow and inexact exceptions. HP-UX disables traps for all floating-point exceptions by default, which is equivalent to using the -ieee compiler option on Tru64 UNIX.
Applications that handle floating-point exceptions through a SIGFPE signal handler will need to explicitly enable traps for those exceptions on HP-UX. Otherwise, the exceptions will be ignored and the handler will never be invoked for them. Identifiers
 SIGFPE |
|
|
|
|
|
See also
Solution description
Enable traps for the appropriate floating-point exceptions.
HP-UX provides the following methods to enable traps for floating-point exceptions:
The +FP compiler option allows you to enable traps from the compiler command line. It is available in all HP compilers.
The +fp_exception option, available with the HP Fortran 90 compiler, enables traps for four IEEE exceptions: invalid
operation, division by zero, overflow, and underflow. (Few programs need to trap for the inexact exception, which occurs often and conveys little information.) The HP FORTRAN/9000 equivalent is +T.
The fesettrapenable function is part of the
fenv(5) suite and is provided in the C math library.
Review the applicable manpages and HP-UX Floating-Point Guide for more information on floating-point exceptions. New behavior
The following example uses the +FP compiler option on HP-UX to get the default
Tru64 UNIX floating-point exception behavior:
% cc +DD64 +FPOVZ foo.c
The following example accomplishes the same thing using the fesettrapenable function:
#include <fenv.h>
/*...*/
#pragma STDC FENV_ACCESS ON
fesettrapenable(FE_OVERFLOW|FE_INVALID|FE_DIVBYZERO); See also
Problem summary
| classifications |
source types |
OS release |
severity |
type |
| SIG |
C, C++, Fortran |
any HP-UX 11i version |
critical |
changed |
|