[PPL-devel] [GIT] ppl/ppl(master): Let bitwise operators be applied to unsigned integer types.

Enea Zaffanella zaffanella at cs.unipr.it
Mon Feb 20 17:32:18 CET 2012


Module: ppl/ppl
Branch: master
Commit: 58a8be4d4b1d493d01074409b87fe34ddfa09c05
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=58a8be4d4b1d493d01074409b87fe34ddfa09c05

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Mon Feb 20 17:27:12 2012 +0100

Let bitwise operators be applied to unsigned integer types.
Detected by ECLAIR service utypflag.

---

 src/Bit_Row.cc        |    2 +-
 src/Float.defs.hh     |   12 ++++++------
 src/Interval.defs.hh  |    3 ++-
 src/intervals.defs.hh |    8 ++++----
 4 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/Bit_Row.cc b/src/Bit_Row.cc
index 47f153c..9fec973 100644
--- a/src/Bit_Row.cc
+++ b/src/Bit_Row.cc
@@ -140,7 +140,7 @@ PPL::Bit_Row::operator[](const unsigned long k) const {
     return false;
 
   mp_limb_t limb = *(vec->_mp_d + i);
-  return ((limb >> (k % GMP_NUMB_BITS)) & 1) != 0;
+  return ((limb >> (k % GMP_NUMB_BITS)) & 1U) != 0;
 }
 
 void
diff --git a/src/Float.defs.hh b/src/Float.defs.hh
index 597b2dc..1b29841 100644
--- a/src/Float.defs.hh
+++ b/src/Float.defs.hh
@@ -59,7 +59,7 @@ struct float_ieee754_half {
   static const unsigned int BASE = 2;
   static const unsigned int EXPONENT_BITS = 5;
   static const unsigned int MANTISSA_BITS = 10;
-  static const int EXPONENT_MAX = (1 << (EXPONENT_BITS - 1)) - 1;
+  static const int EXPONENT_MAX = (1U << (EXPONENT_BITS - 1)) - 1;
   static const int EXPONENT_BIAS = EXPONENT_MAX;
   static const int EXPONENT_MIN = -EXPONENT_MAX + 1;
   static const int EXPONENT_MIN_DENORM = EXPONENT_MIN
@@ -92,7 +92,7 @@ struct float_ieee754_single {
   static const unsigned int BASE = 2;
   static const unsigned int EXPONENT_BITS = 8;
   static const unsigned int MANTISSA_BITS = 23;
-  static const int EXPONENT_MAX = (1 << (EXPONENT_BITS - 1)) - 1;
+  static const int EXPONENT_MAX = (1U << (EXPONENT_BITS - 1)) - 1;
   static const int EXPONENT_BIAS = EXPONENT_MAX;
   static const int EXPONENT_MIN = -EXPONENT_MAX + 1;
   static const int EXPONENT_MIN_DENORM = EXPONENT_MIN
@@ -138,7 +138,7 @@ struct float_ieee754_double {
   static const unsigned int BASE = 2;
   static const unsigned int EXPONENT_BITS = 11;
   static const unsigned int MANTISSA_BITS = 52;
-  static const int EXPONENT_MAX = (1 << (EXPONENT_BITS - 1)) - 1;
+  static const int EXPONENT_MAX = (1U << (EXPONENT_BITS - 1)) - 1;
   static const int EXPONENT_BIAS = EXPONENT_MAX;
   static const int EXPONENT_MIN = -EXPONENT_MAX + 1;
   static const int EXPONENT_MIN_DENORM = EXPONENT_MIN
@@ -171,7 +171,7 @@ struct float_ibm_single {
   static const unsigned int EXPONENT_BITS = 7;
   static const unsigned int MANTISSA_BITS = 24;
   static const int EXPONENT_BIAS = 64;
-  static const int EXPONENT_MAX = (1 << (EXPONENT_BITS - 1)) - 1;
+  static const int EXPONENT_MAX = (1U << (EXPONENT_BITS - 1)) - 1;
   static const int EXPONENT_MIN = -EXPONENT_MAX + 1;
   static const int EXPONENT_MIN_DENORM = EXPONENT_MIN
 					- static_cast<int>(MANTISSA_BITS);
@@ -222,7 +222,7 @@ struct float_intel_double_extended {
   static const unsigned int BASE = 2;
   static const unsigned int EXPONENT_BITS = 15;
   static const unsigned int MANTISSA_BITS = 63;
-  static const int EXPONENT_MAX = (1 << (EXPONENT_BITS - 1)) - 1;
+  static const int EXPONENT_MAX = (1U << (EXPONENT_BITS - 1)) - 1;
   static const int EXPONENT_BIAS = EXPONENT_MAX;
   static const int EXPONENT_MIN = -EXPONENT_MAX + 1;
   static const int EXPONENT_MIN_DENORM = EXPONENT_MIN
@@ -263,7 +263,7 @@ struct float_ieee754_quad {
   static const unsigned int BASE = 2;
   static const unsigned int EXPONENT_BITS = 15;
   static const unsigned int MANTISSA_BITS = 112;
-  static const int EXPONENT_MAX = (1 << (EXPONENT_BITS - 1)) - 1;
+  static const int EXPONENT_MAX = (1U << (EXPONENT_BITS - 1)) - 1;
   static const int EXPONENT_BIAS = EXPONENT_MAX;
   static const int EXPONENT_MIN = -EXPONENT_MAX + 1;
   static const int EXPONENT_MIN_DENORM = EXPONENT_MIN
diff --git a/src/Interval.defs.hh b/src/Interval.defs.hh
index bd0045b..843d17e 100644
--- a/src/Interval.defs.hh
+++ b/src/Interval.defs.hh
@@ -41,7 +41,8 @@ enum Ternary { T_YES, T_NO, T_MAYBE };
 
 inline I_Result
 combine(Result l, Result u) {
-  return static_cast<I_Result>(l | (u << 6));
+  unsigned res = static_cast<unsigned>(l) | (static_cast<unsigned>(u) << 6);
+  return static_cast<I_Result>(res);
 }
 
 struct Interval_Base {
diff --git a/src/intervals.defs.hh b/src/intervals.defs.hh
index 072b406..29c1081 100644
--- a/src/intervals.defs.hh
+++ b/src/intervals.defs.hh
@@ -33,13 +33,13 @@ namespace Parma_Polyhedra_Library {
 
 enum I_Result {
   //! The resulting set may be empty
-  I_EMPTY = 1,
+  I_EMPTY = 1U,
   //! The resulting set may have only one value
-  I_SINGLETON = 2,
+  I_SINGLETON = 2U,
   //! The resulting set may have more than one value and to be not the domain universe
-  I_SOME = 4,
+  I_SOME = 4U,
   //! The resulting set may be the domain universe
-  I_UNIVERSE = 8,
+  I_UNIVERSE = 8U,
   //! The resulting set is not empty
   I_NOT_EMPTY = I_SINGLETON | I_SOME | I_UNIVERSE,
   //! The resulting set may be empty or not empty




More information about the PPL-devel mailing list