class
FloatingPointExceptionsManage floating-point exceptions via signal handlers at runtime.
This class allows you to enable or disable specific floating-point exceptions such as:
- FE_DIVBYZERO
- FE_INVALID
- FE_OVERFLOW
- FE_UNDERFLOW
- FE_INEXACT
When enabled, triggering one of these exceptions will raise a SIGFPE (or SIGILL on Apple ARM64) on events such as division by zero or overflow, and a custom signal handler will print diagnostic information and terminate the process allowing detection and debugging of numerical issues.
Public static functions
-
static void enable_floating_point_exceptions(const std::
string& names = "FE_DIVBYZERO, FE_INVALID, FE_OVERFLOW") - Enable/unmask specific floating-point exceptions. Use "FE_ALL_EXCEPT" to enable all exceptions.
-
static void disable_floating_point_exceptions(const std::
string& names = "FE_ALL_EXCEPT") - Disable/mask specific floating-point exceptions. Use "FE_ALL_EXCEPT" to disable all exceptions.
- static void enable_custom_signal_handlers(bool force = false)
- Enable/install custom signal handlers to trigger on a raised floating-point exception.
- static void disable_custom_signal_handlers()
- Disable/restore original custom signal handlers saved by enable_custom_signal_handlers.
-
static void test(const std::
string& names = "FE_ALL_EXCEPT") - Test floating-point exceptions raising for the specified names.
Function documentation
static void eckit:: maths:: FloatingPointExceptions:: enable_floating_point_exceptions(const std:: string& names = "FE_DIVBYZERO, FE_INVALID, FE_OVERFLOW")
Enable/unmask specific floating-point exceptions. Use "FE_ALL_EXCEPT" to enable all exceptions.
Parameters | |
---|---|
names | Comma-separated string of exception names. |
static void eckit:: maths:: FloatingPointExceptions:: disable_floating_point_exceptions(const std:: string& names = "FE_ALL_EXCEPT")
Disable/mask specific floating-point exceptions. Use "FE_ALL_EXCEPT" to disable all exceptions.
Parameters | |
---|---|
names | Cmma-separated string of exception names. |
static void eckit:: maths:: FloatingPointExceptions:: enable_custom_signal_handlers(bool force = false)
Enable/install custom signal handlers to trigger on a raised floating-point exception.
Parameters | |
---|---|
force | Installs signal handlers if force=true, or if force=false and floating-point exceptions have been enabled by this mechanism. |
Installs custom signal handlers, platform-dependent SIGFPE (and SIGILL on Apple ARM64), saving the current (original) ones.
static void eckit:: maths:: FloatingPointExceptions:: test(const std:: string& names = "FE_ALL_EXCEPT")
Test floating-point exceptions raising for the specified names.
Parameters | |
---|---|
names | Cmma-separated string of exception names. |