[PPL-devel] [GIT] ppl/ppl(master): Avoid implicit conversion changing type signedness.

Enea Zaffanella zaffanella at cs.unipr.it
Wed Feb 22 21:06:42 CET 2012


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

Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date:   Wed Feb 22 21:05:33 2012 +0100

Avoid implicit conversion changing type signedness.
Detected by ECLAIR service utypflag.

---

 src/Linear_Row.inlines.hh    |    2 +-
 src/Linear_System.cc         |   10 +++++++---
 src/Linear_System.inlines.hh |    2 +-
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/Linear_Row.inlines.hh b/src/Linear_Row.inlines.hh
index 571a7e3..b690b00 100644
--- a/src/Linear_Row.inlines.hh
+++ b/src/Linear_Row.inlines.hh
@@ -158,7 +158,7 @@ Linear_Row::space_dimension() const {
   const dimension_type sz = size();
   return (sz == 0)
     ? 0
-    : (sz - (is_necessarily_closed() ? 1 : 2));
+    : (sz - (is_necessarily_closed() ? 1U : 2U));
 }
 
 inline
diff --git a/src/Linear_System.cc b/src/Linear_System.cc
index 9d7255c..506b507 100644
--- a/src/Linear_System.cc
+++ b/src/Linear_System.cc
@@ -520,13 +520,17 @@ PPL::Linear_System::sort_and_remove_with_sat(Bit_Matrix& sat) {
 
   // First, sort `sys' (keeping `sat' consistent) without removing duplicates.
   With_Bit_Matrix_iterator first(sys.rows.begin(), sat.rows.begin());
-  With_Bit_Matrix_iterator last = first + sat.num_rows();
+  typedef With_Bit_Matrix_iterator::difference_type diff_type;
+  With_Bit_Matrix_iterator last
+    = first + static_cast<diff_type>(sat.num_rows());
   Implementation::swapping_sort(first, last, Row_Less_Than());
   // Second, move duplicates in `sys' to the end (keeping `sat' consistent).
   With_Bit_Matrix_iterator new_last
     = Implementation::swapping_unique(first, last);
 
-  const dimension_type num_duplicates = last - new_last;
+  const diff_type dist = last - new_last;
+  PPL_ASSERT(dist >= 0);
+  const dimension_type num_duplicates = static_cast<dimension_type>(dist);
   const dimension_type new_first_pending_row
     = sys.first_pending_row() - num_duplicates;
 
@@ -879,7 +883,7 @@ PPL::Linear_System::OK(const bool check_strong_normalized) const {
   // A non-empty system will contain constraints or generators; in
   // both cases it must have at least one column for the inhomogeneous
   // term and, if it is NNC, another one for the epsilon coefficient.
-  const dimension_type min_cols = is_necessarily_closed() ? 1 : 2;
+  const dimension_type min_cols = is_necessarily_closed() ? 1U : 2U;
   if (num_columns() < min_cols) {
 #ifndef NDEBUG
     cerr << "Linear_System has fewer columns than the minimum "
diff --git a/src/Linear_System.inlines.hh b/src/Linear_System.inlines.hh
index b8d999c..9ed4694 100644
--- a/src/Linear_System.inlines.hh
+++ b/src/Linear_System.inlines.hh
@@ -204,7 +204,7 @@ Linear_System::space_dimension() const {
   const dimension_type n_columns = num_columns();
   return (n_columns == 0)
     ? 0
-    : (n_columns - (is_necessarily_closed() ? 1 : 2));
+    : (n_columns - (is_necessarily_closed() ? 1U : 2U));
 }
 
 inline void




More information about the PPL-devel mailing list