Skip to content

Commit

Permalink
Merge pull request #272 from ikuokuo/master
Browse files Browse the repository at this point in the history
Fixed half errhandling throw except
  • Loading branch information
JohanMabille authored Nov 6, 2023
2 parents 3303ffd + 88f154d commit 7b9f7bb
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion include/xtl/xhalf_float_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3996,14 +3996,31 @@ namespace half_float {
/// \throw std::range_error if `FE_INEXACT` is selected and set
inline void fethrowexcept(int excepts, const char *msg = "") {
excepts &= detail::errflags();
if(excepts & (FE_INVALID|FE_DIVBYZERO))
#if HALF_ERRHANDLING_THROWS
#ifdef HALF_ERRHANDLING_THROW_INVALID
if(excepts & FE_INVALID)
throw std::domain_error(msg);
#endif
#ifdef HALF_ERRHANDLING_THROW_DIVBYZERO
if(excepts & FE_DIVBYZERO)
throw std::domain_error(msg);
#endif
#ifdef HALF_ERRHANDLING_THROW_OVERFLOW
if(excepts & FE_OVERFLOW)
throw std::overflow_error(msg);
#endif
#ifdef HALF_ERRHANDLING_THROW_UNDERFLOW
if(excepts & FE_UNDERFLOW)
throw std::underflow_error(msg);
#endif
#ifdef HALF_ERRHANDLING_THROW_INEXACT
if(excepts & FE_INEXACT)
throw std::range_error(msg);
#endif
#else
std::fprintf(stderr, "%s\n", msg);
std::terminate();
#endif
}
/// \}
}
Expand Down

0 comments on commit 7b9f7bb

Please sign in to comment.