-qflttrap

Category

Error checking and debugging

Pragma equivalent

#pragma options [no]flttrap

Purpose

Determines the types of floating-point exception conditions to be detected at run time

Syntax

Read syntax diagramSkip visual syntax diagram
        .-noflttrap------------------------------.   
>>- -q--+-flttrap--+---------------------------+-+-------------><
                   |    .-:------------------. |     
                   |    |   .-zero-------.   | |     
                   |    |   +-zerodivide-+   | |     
                   |    |   +-und--------+   | |     
                   |    |   +-underflow--+   | |     
                   |    |   +-ov---------+   | |     
                   |    |   +-overflow---+   | |     
                   |    |   +-inv--------+   | |     
                   |    |   +-invalid----+   | |     
                   |    |   +-inex-------+   | |     
                   |    V   +-inexact----+   | |     
                   '-=------+-enable-----+---+-'     
                            +-en---------+           
                            '-nanq-------'           

Defaults

-qnoflttrap

Parameters

enable, en
Enables trapping when the specified exceptions (overflow, underflow, zerodivide, invalid, or inexact) occur. You must specify this suboption if you want to turn on exception trapping without modifying your source code. If any of the specified exceptions occur, a SIGTRAP or SIGFPE signal is sent to the process with the precise location of the exception.
inexact, inex
Enables the detection of floating-point inexact operations. If a floating-point inexact operation occurs, an inexact operation exception status flag is set in the Floating-Point Status and Control Register (FPSCR).
invalid, inv
Enables the detection of floating-point invalid operations. If a floating-point invalid operation occurs, an invalid operation exception status flag is set in the FPSCR.
nanq
Generates code to detect NaNQ (Not a Number Quiet) and NaNS (Not a Number Signalling) exceptions before and after each floating point operation, including assignment, and after each call to a function returning a floating-point result to trap if the value is a NaN. Trapping code is generated regardless of whether the enable suboption is specified.
overflow, ov
Enables the detection of floating-point overflow. If a floating-point overflow occurs, an overflow exception status flag is set in the FPSCR.
underflow, und
Enables the detection of floating-point underflow. If a floating-point underflow occurs, an underflow exception status flag is set in the FPSCR.
zerodivide, zero
Enables the detection of floating-point division by zero. If a floating-point zero-divide occurs, a zero-divide exception status flag is set in the FPSCR.
Specifying -qflttrap option with no suboptions is equivalent to -qflttrap=overflow : underflow : zerodivide : invalid : inexact. Exceptions will be detected by the hardware, but trapping is not enabled. Because this default does not include enable, it is probably only useful if you already use fpsets or similar subroutines in your source.

Usage

It is recommended that you use the enable suboption whenever compiling the main program with -qflttrap. This ensures that the compiler will generate the code to automatically enable floating-point exception trapping, without requiring that you include calls to the appropriate floating-point exception library functions in your code.

If you specify -qflttrap more than once, both with and without suboptions, the -qflttrap without suboptions is ignored.

This option is recognized during linking with IPA. Specifying the option at the link step overrides the compile-time setting.

If your program contains signalling NaNs, you should use the -qfloat=nans option along with -qflttrap to trap any exceptions.

The compiler exhibits behavior as illustrated in the following examples when the -qflttrap option is specified together with an optimization option:

Note: Due to the transformations performed and the exception handling support of some vector instructions, use of -qsimd=auto may change the location where an exception is caught or even cause the compiler to miss catching an exception.

Predefined macros

None.

Examples

When you compile this program:
#include <stdio.h>

int main()
{
  float x, y, z;
  x = 5.0;
  y = 0.0;
  z = x / y;
  printf("%f", z);
}      
with the command:
xlc -qflttrap=zerodivide:enable divide_by_zero.c
the program stops when the division is performed.

The zerodivide suboption identifies the type of exception to guard against. The enable suboption causes a SIGTRAP or SIGFPE signal to be generated when the exception occurs.

Related information