diff --git a/src/H5Tinit_float.c b/src/H5Tinit_float.c index 30f6c0544ea..6a96650dbb9 100644 --- a/src/H5Tinit_float.c +++ b/src/H5Tinit_float.c @@ -461,10 +461,17 @@ H5T__init_native_float_types(void) { H5T_fpoint_det_t det; H5T_t *dt = NULL; + int fpe_flags = 0; herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE + /* Turn off floating-point exceptions while initializing to avoid + * tripping over signalling NaNs while looking at "don't care" bits. + */ + fpe_flags = fegetexcept(); + fedisableexcept(FE_INVALID); + /* H5T_NATIVE_FLOAT */ /* Get the type's characteristics */ @@ -564,6 +571,9 @@ H5T__init_native_float_types(void) H5T_native_order_g = det.order; done: + /* Restore the original exceptions */ + feenableexcept(fpe_flags); + if (ret_value < 0) { if (dt != NULL) { dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); diff --git a/src/H5private.h b/src/H5private.h index 14a0ac3225f..3aaa0d52453 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include