
Module: ppl/ppl Branch: master Commit: 7f72ff168aa3989740f248c1fbe636f01157a9e6 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=7f72ff168aa39...
Author: Abramo Bagnara abramo.bagnara@gmail.com Date: Thu Nov 3 16:13:06 2011 +0100
Fixed bool vs. numeric unsafe mixing. Detected by ECLAIR service utypflag.
---
src/checked_float.inlines.hh | 6 +++--- src/fpu-c99.inlines.hh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/checked_float.inlines.hh b/src/checked_float.inlines.hh index 5f91f67..c6ed19a 100644 --- a/src/checked_float.inlines.hh +++ b/src/checked_float.inlines.hh @@ -801,12 +801,12 @@ set_pos_overflow_float(T& to, Rounding_Dir dir) { template <typename To_Policy, typename From_Policy, typename T> inline Result assign_float_mpz(T& to, const mpz_class& from, Rounding_Dir dir) { - mpz_srcptr from_z = from.get_mpz_t(); - int sign = mpz_sgn(from_z); + int sign = sgn(from); if (sign == 0) { to = 0; return V_EQ; } + mpz_srcptr from_z = from.get_mpz_t(); size_t exponent = mpz_sizeinbase(from_z, 2) - 1; if (exponent > size_t(Float<T>::Binary::EXPONENT_MAX)) { if (sign < 0) @@ -846,7 +846,7 @@ assign_float_mpq(T& to, const mpq_class& from, Rounding_Dir dir) { return assign_float_mpz<To_Policy, From_Policy>(to, num, dir); mpz_srcptr num_z = num.get_mpz_t(); mpz_srcptr den_z = den.get_mpz_t(); - int sign = mpz_sgn(num_z); + int sign = sgn(num); signed long exponent = mpz_sizeinbase(num_z, 2) - mpz_sizeinbase(den_z, 2); if (exponent < Float<T>::Binary::EXPONENT_MIN_DENORM) { to = 0; diff --git a/src/fpu-c99.inlines.hh b/src/fpu-c99.inlines.hh index 7fc12de..cda7a4c 100644 --- a/src/fpu-c99.inlines.hh +++ b/src/fpu-c99.inlines.hh @@ -87,7 +87,7 @@ fpu_restore_rounding_direction(fpu_rounding_control_word_type w) { inline int fpu_check_inexact() { #if PPL_CXX_SUPPORTS_IEEE_INEXACT_FLAG - return fetestexcept(FE_INEXACT) != 0; + return fetestexcept(FE_INEXACT) != 0 ? 1 : 0; #else return -1; #endif