Sets the IEEE trapping mode in effect at start-up.
This option sets the IEEE 754 trapping modes that are established at program initialization, but does not install a SIGFPE handler. You can use ieee_handler to simultaneously enable traps and install a SIGFPE handler. When more than one value is used, the list is processed sequentially from left to right.
t is a comma-separated list that consists of one or more of the following:
Value of t |
Meaning |
---|---|
[no%]division |
[Do not] Trap on division by zero. |
[no%]inexact |
[Do not] Trap on inexact result. |
[no%]invalid |
[Do not] Trap on invalid operation |
[no%]overflow |
[Do not] Trap on overflow. |
[no%]underflow |
[Do not] Trap on underflow. |
%all |
Trap on all of the above. |
%none |
Trap on none of the above. |
common |
Trap on invalid, division by zero, and overflow. |
Note that the [no%] form of the option is used only to modify the meaning of the %all and common values, and must be used with one of these values, as shown in the example. The [no%] form of the option by itself does not explicitly cause a particular trap to be disabled.
If you wish to enable the IEEE traps, -ftrap=common is the recommended setting.
If -ftrap is not specified, the -ftrap=%none value is assumed. (Traps are not enabled automatically.)
When one or more terms are given, the list is processed sequentially from left to right, thus -ftrap=%all,no%inexact means to set all traps except inexact.
The mode can be changed at runtime with ieee_handler(3M).
If you compile one routine with -ftrap=t, compile all routines of the program with the same -ftrap=t option; otherwise, you might get unexpected results.
Use the -ftrap=inexact trap with caution. Use of -ftrap=inexact results in the trap being issued whenever a floating-point value cannot be represented exactly. For example, the following statement generates this condition:
x = 1.0 / 3.0;
This option is effective only if used when compiling the main program. Be cautious when using this option. If you wish to enable the IEEE traps, use -ftrap=common.
ieee_handler(3M) man page