Skip to content

Commit 7b9f7bb

Browse files
authored
Merge pull request #272 from ikuokuo/master
Fixed half errhandling throw except
2 parents 3303ffd + 88f154d commit 7b9f7bb

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

include/xtl/xhalf_float_impl.hpp

+18-1
Original file line numberDiff line numberDiff line change
@@ -3996,14 +3996,31 @@ namespace half_float {
39963996
/// \throw std::range_error if `FE_INEXACT` is selected and set
39973997
inline void fethrowexcept(int excepts, const char *msg = "") {
39983998
excepts &= detail::errflags();
3999-
if(excepts & (FE_INVALID|FE_DIVBYZERO))
3999+
#if HALF_ERRHANDLING_THROWS
4000+
#ifdef HALF_ERRHANDLING_THROW_INVALID
4001+
if(excepts & FE_INVALID)
40004002
throw std::domain_error(msg);
4003+
#endif
4004+
#ifdef HALF_ERRHANDLING_THROW_DIVBYZERO
4005+
if(excepts & FE_DIVBYZERO)
4006+
throw std::domain_error(msg);
4007+
#endif
4008+
#ifdef HALF_ERRHANDLING_THROW_OVERFLOW
40014009
if(excepts & FE_OVERFLOW)
40024010
throw std::overflow_error(msg);
4011+
#endif
4012+
#ifdef HALF_ERRHANDLING_THROW_UNDERFLOW
40034013
if(excepts & FE_UNDERFLOW)
40044014
throw std::underflow_error(msg);
4015+
#endif
4016+
#ifdef HALF_ERRHANDLING_THROW_INEXACT
40054017
if(excepts & FE_INEXACT)
40064018
throw std::range_error(msg);
4019+
#endif
4020+
#else
4021+
std::fprintf(stderr, "%s\n", msg);
4022+
std::terminate();
4023+
#endif
40074024
}
40084025
/// \}
40094026
}

0 commit comments

Comments
 (0)