[PPL-devel] [GIT] ppl/ppl(master): Fixed bool vs. numeric unsafe mixing.
Abramo Bagnara
abramo.bagnara at gmail.com
Thu Nov 3 10:33:37 CET 2011
Module: ppl/ppl
Branch: master
Commit: 8eebe6d762e82c521dd7c0be6206df2928e4fcb1
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=8eebe6d762e82c521dd7c0be6206df2928e4fcb1
Author: Abramo Bagnara <abramo.bagnara at gmail.com>
Date: Thu Nov 3 10:15:26 2011 +0100
Fixed bool vs. numeric unsafe mixing.
Detected by ECLAIR service utypflag.
---
src/Float.defs.hh | 24 ++++++++++++------------
src/Float.inlines.hh | 24 ++++++++++++------------
src/Interval_Info.defs.hh | 2 +-
src/checked.cc | 2 +-
4 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/src/Float.defs.hh b/src/Float.defs.hh
index 541b9df..1e50ecc 100644
--- a/src/Float.defs.hh
+++ b/src/Float.defs.hh
@@ -66,9 +66,9 @@ struct float_ieee754_half {
- static_cast<int>(MANTISSA_BITS);
static const Floating_Point_Format floating_point_format = IEEE754_HALF;
int is_inf() const;
- int is_nan() const;
+ bool is_nan() const;
int is_zero() const;
- int sign_bit() const;
+ bool sign_bit() const;
void negate();
void dec();
void inc();
@@ -99,9 +99,9 @@ struct float_ieee754_single {
- static_cast<int>(MANTISSA_BITS);
static const Floating_Point_Format floating_point_format = IEEE754_SINGLE;
int is_inf() const;
- int is_nan() const;
+ bool is_nan() const;
int is_zero() const;
- int sign_bit() const;
+ bool sign_bit() const;
void negate();
void dec();
void inc();
@@ -145,9 +145,9 @@ struct float_ieee754_double {
- static_cast<int>(MANTISSA_BITS);
static const Floating_Point_Format floating_point_format = IEEE754_DOUBLE;
int is_inf() const;
- int is_nan() const;
+ bool is_nan() const;
int is_zero() const;
- int sign_bit() const;
+ bool sign_bit() const;
void negate();
void dec();
void inc();
@@ -177,9 +177,9 @@ struct float_ibm_single {
- static_cast<int>(MANTISSA_BITS);
static const Floating_Point_Format floating_point_format = IBM_SINGLE;
int is_inf() const;
- int is_nan() const;
+ bool is_nan() const;
int is_zero() const;
- int sign_bit() const;
+ bool sign_bit() const;
void negate();
void dec();
void inc();
@@ -230,9 +230,9 @@ struct float_intel_double_extended {
static const Floating_Point_Format floating_point_format =
INTEL_DOUBLE_EXTENDED;
int is_inf() const;
- int is_nan() const;
+ bool is_nan() const;
int is_zero() const;
- int sign_bit() const;
+ bool sign_bit() const;
void negate();
void dec();
void inc();
@@ -269,9 +269,9 @@ struct float_ieee754_quad {
static const int EXPONENT_MIN_DENORM = EXPONENT_MIN
- static_cast<int>(MANTISSA_BITS);
int is_inf() const;
- int is_nan() const;
+ bool is_nan() const;
int is_zero() const;
- int sign_bit() const;
+ bool sign_bit() const;
void negate();
void dec();
void inc();
diff --git a/src/Float.inlines.hh b/src/Float.inlines.hh
index ba3a42b..a456606 100644
--- a/src/Float.inlines.hh
+++ b/src/Float.inlines.hh
@@ -39,7 +39,7 @@ float_ieee754_half::is_inf() const {
return 0;
}
-inline int
+inline bool
float_ieee754_half::is_nan() const {
return (word & ~SGN_MASK) > POS_INF;
}
@@ -58,7 +58,7 @@ float_ieee754_half::negate() {
word ^= SGN_MASK;
}
-inline int
+inline bool
float_ieee754_half::sign_bit() const {
return !!(word & SGN_MASK);
}
@@ -100,7 +100,7 @@ float_ieee754_single::is_inf() const {
return 0;
}
-inline int
+inline bool
float_ieee754_single::is_nan() const {
return (word & ~SGN_MASK) > POS_INF;
}
@@ -119,7 +119,7 @@ float_ieee754_single::negate() {
word ^= SGN_MASK;
}
-inline int
+inline bool
float_ieee754_single::sign_bit() const {
return !!(word & SGN_MASK);
}
@@ -163,7 +163,7 @@ float_ieee754_double::is_inf() const {
return 0;
}
-inline int
+inline bool
float_ieee754_double::is_nan() const {
uint32_t a = msp & ~MSP_SGN_MASK;
return a > MSP_POS_INF || (a == MSP_POS_INF && lsp != LSP_INF);
@@ -185,7 +185,7 @@ float_ieee754_double::negate() {
msp ^= MSP_SGN_MASK;
}
-inline int
+inline bool
float_ieee754_double::sign_bit() const {
return !!(msp & MSP_SGN_MASK);
}
@@ -247,7 +247,7 @@ float_ibm_single::is_inf() const {
return 0;
}
-inline int
+inline bool
float_ibm_single::is_nan() const {
return (word & ~SGN_MASK) > POS_INF;
}
@@ -266,7 +266,7 @@ float_ibm_single::negate() {
word ^= SGN_MASK;
}
-inline int
+inline bool
float_ibm_single::sign_bit() const {
return !!(word & SGN_MASK);
}
@@ -311,7 +311,7 @@ float_intel_double_extended::is_inf() const {
return 0;
}
-inline int
+inline bool
float_intel_double_extended::is_nan() const {
return (msp & MSP_POS_INF) == MSP_POS_INF
&& lsp != LSP_INF;
@@ -334,7 +334,7 @@ float_intel_double_extended::negate() {
msp ^= MSP_SGN_MASK;
}
-inline int
+inline bool
float_intel_double_extended::sign_bit() const {
return !!(msp & MSP_SGN_MASK);
}
@@ -392,7 +392,7 @@ float_ieee754_quad::is_inf() const {
return 0;
}
-inline int
+inline bool
float_ieee754_quad::is_nan() const {
return (msp & ~MSP_SGN_MASK) == MSP_POS_INF
&& lsp != LSP_INF;
@@ -414,7 +414,7 @@ float_ieee754_quad::negate() {
msp ^= MSP_SGN_MASK;
}
-inline int
+inline bool
float_ieee754_quad::sign_bit() const {
return !!(msp & MSP_SGN_MASK);
}
diff --git a/src/Interval_Info.defs.hh b/src/Interval_Info.defs.hh
index 3c12f2f..9312dfd 100644
--- a/src/Interval_Info.defs.hh
+++ b/src/Interval_Info.defs.hh
@@ -178,7 +178,7 @@ public:
const_int_nodef(upper_open_bit, upper_special_bit + store_special);
const_int_nodef(upper_normalized_bit, upper_open_bit + store_open);
const_int_nodef(cardinality_is_bit, upper_normalized_bit + cache_normalized);
- const_int_nodef(cardinality_0_bit, cardinality_is_bit + (cache_empty || cache_singleton));
+ const_int_nodef(cardinality_0_bit, cardinality_is_bit + ((cache_empty || cache_singleton) ? 1 : 0));
const_int_nodef(cardinality_1_bit, cardinality_0_bit + cache_empty);
const_int_nodef(next_bit, cardinality_1_bit + cache_singleton);
Interval_Info_Bitset() {
diff --git a/src/checked.cc b/src/checked.cc
index 842611f..ed71a67 100644
--- a/src/checked.cc
+++ b/src/checked.cc
@@ -404,7 +404,7 @@ input_mpq(mpq_class& to, std::istream& is) {
mpz_ptr den = to.get_den().get_mpz_t();
mpz_set_str(num, num_struct.mantissa.c_str(), num_struct.base);
if (den_struct.base) {
- if (num_struct.neg_mantissa ^ den_struct.neg_mantissa)
+ if (num_struct.neg_mantissa != den_struct.neg_mantissa)
mpz_neg(num, num);
mpz_set_str(den, den_struct.mantissa.c_str(), den_struct.base);
if (num_struct.exponent || den_struct.exponent) {
More information about the PPL-devel
mailing list