The IEEE standard for floating-point arithmetic specifies that five types of exceptions be signalled when detected:
By default, the signalling of an exception involves setting a status flag and continuing. The standard also allows for an exception to generate a trap and invoke a handler routine specified by the user.
The flttrap option directs the compiler to produce code that generates a TRAP signal to flag the occurrence of any enabled floating-point exception. Exception types can be specified with the flttrap option. Each of the five exception types is controlled by a separate suboption:
OVerflow | Generates code to detect and trap floating-point overflow. |
UNDerflow | Generates code to detect and trap floating-point underflow. |
ZEROdivide | Generates code to detect and trap floating-point division by zero. |
INValid | Generates code to detect and trap floating-point invalid-operation exceptions. |
INEXact | Generates code to detect and trap floating-point inexact exceptions. |
The exceptions are enabled using the -qflttrap=enable option or the Base Operating System (BOS) Runtime Service routine fp_enable. The enable suboption inserts code into the prologue of the main program to enable the exceptions specified by the -qflttrap option. The suboption has no effect on source files that do not contain a main program.
The -qflttrap=imprecise suboption generates code that checks for the specified exceptions only on entry and exit to functions that perform floating-point computations. If an exception occurs, it is detected, but the exact location of the exception is not determined. When the imprecise suboption is not specified, each floating-point operation in the code compiled with the -qflttrap option is checked. Unless the exception occurred during a call to another function that was not compiled with -qflttrap (for example, a library routine), the exact location of any exception is identified.
Specifying the -qflttrap option with no suboptions is equivalent to setting
-qflttrap=ov:und:zero:inv:inex
The exceptions are not automatically enabled, and all floating-point operations are checked to provide precise exception-location information.
By default, the TRAP signals generated by enabled exceptions cause a program to stop. Alternatively, the exceptions can be acted upon by a program by providing a routine that is to be invoked when a TRAP signal occurs, and by calling the BOS Runtime Service routine to specify that routine as the handler of TRAP signals. In these respects, the implementation of -qflttrap does not fully support the exception-handling environment suggested by the IEEE floating-point standard.
Floating-point exceptions are described in the AIX Version 4 Assembler Language Reference. The TRAP signal handler sample illustrates the detection and handling of floating-point exceptions.
Overview
-qfloat=nomaf
-qfloat=hssngl
-qfloat=nans
-qfloat=hsflt
-qfloat=rndsngl
float Compiler Option
flttrap Compiler Option