[PPL-devel] [GIT] ppl/ppl(master): Avoided som implicit integral conversion that changed the signedness of the underlying type .
Roberto Bagnara
bagnara at cs.unipr.it
Sat Aug 18 09:52:05 CEST 2012
Module: ppl/ppl
Branch: master
Commit: ec76e739bace356dfd557bb9bd85040ad65c2e8f
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=ec76e739bace356dfd557bb9bd85040ad65c2e8f
Author: Roberto Bagnara <bagnara at cs.unipr.it>
Date: Sat Aug 18 09:50:09 2012 +0200
Avoided som implicit integral conversion that changed the signedness of the underlying type.
Detected by ECLAIR service utypflag.
---
demos/ppl_lcdd/ppl_lcdd.cc | 6 +++---
demos/ppl_pips/ppl_pips.cc | 16 ++++++++++------
src/Polyhedron_conversion.templates.hh | 2 +-
src/Polyhedron_minimize.templates.hh | 2 +-
4 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/demos/ppl_lcdd/ppl_lcdd.cc b/demos/ppl_lcdd/ppl_lcdd.cc
index 744c696..0ce9dce 100644
--- a/demos/ppl_lcdd/ppl_lcdd.cc
+++ b/demos/ppl_lcdd/ppl_lcdd.cc
@@ -409,21 +409,21 @@ process_options(int argc, char* argv[]) {
if (*endptr || l < 0)
fatal("a non-negative integer must follow `-C'");
else
- max_seconds_of_cpu_time = l;
+ max_seconds_of_cpu_time = static_cast<unsigned long>(l);
break;
#endif // defined(PPL_LCDD_SUPPORTS_LIMIT_ON_CPU_TIME)
case 'R':
{
- const int MEGA = 1024*1024;
+ const unsigned long MEGA = 1024U*1024U;
l = strtol(optarg, &endptr, 10);
if (*endptr || l < 0)
fatal("a non-negative integer must follow `-R'");
else if (static_cast<unsigned long>(l) > ULONG_MAX/MEGA)
max_bytes_of_virtual_memory = ULONG_MAX;
else
- max_bytes_of_virtual_memory = l*MEGA;
+ max_bytes_of_virtual_memory = static_cast<unsigned long>(l)*MEGA;
}
break;
diff --git a/demos/ppl_pips/ppl_pips.cc b/demos/ppl_pips/ppl_pips.cc
index b60d2ce..f5854df 100644
--- a/demos/ppl_pips/ppl_pips.cc
+++ b/demos/ppl_pips/ppl_pips.cc
@@ -282,6 +282,7 @@ public:
std::istringstream iss(line);
iss >> bignum_column_coding;
}
+ PPL_ASSERT(bignum_column_coding >= -1);
PPL::dimension_type num_constraints;
PPL::dimension_type constraint_width;
@@ -305,9 +306,10 @@ public:
}
}
- PPL::dimension_type bignum_column = (bignum_column_coding == -1)
+ PPL::dimension_type bignum_column
+ = (bignum_column_coding == -1)
? PPL::not_a_dimension()
- : (num_vars + (bignum_column_coding - 1));
+ : (num_vars + PPL::dimension_type(bignum_column_coding - 1));
bool result = update_pip(num_vars, num_params,
num_constraints, num_ctx_rows,
@@ -349,9 +351,11 @@ public:
int bignum_column_coding;
in >> bignum_column_coding;
- PPL::dimension_type bignum_column = (bignum_column_coding == -1)
+ PPL_ASSERT(bignum_column_coding >= -1);
+ PPL::dimension_type bignum_column
+ = (bignum_column_coding == -1)
? PPL::not_a_dimension()
- : (bignum_column_coding - 1);
+ : PPL::dimension_type(bignum_column_coding - 1);
int solve_integer;
in >> solve_integer;
@@ -647,14 +651,14 @@ process_options(int argc, char* argv[]) {
case 'R':
{
- const int MEGA = 1024*1024;
+ const unsigned long MEGA = 1024U*1024U;
long l = strtol(optarg, &endptr, 10);
if (*endptr || l < 0)
fatal("a non-negative integer must follow `-R'");
else if (static_cast<unsigned long>(l) > ULONG_MAX/MEGA)
max_bytes_of_virtual_memory = ULONG_MAX;
else
- max_bytes_of_virtual_memory = l*MEGA;
+ max_bytes_of_virtual_memory = static_cast<unsigned long>(l)*MEGA;
}
break;
diff --git a/src/Polyhedron_conversion.templates.hh b/src/Polyhedron_conversion.templates.hh
index 0f2451d..041904c 100644
--- a/src/Polyhedron_conversion.templates.hh
+++ b/src/Polyhedron_conversion.templates.hh
@@ -362,7 +362,7 @@ Polyhedron::conversion(Source_Linear_System& source,
const dimension_type source_space_dim = source.space_dimension();
const dimension_type source_num_rows = source.num_rows();
const dimension_type source_num_columns = source_space_dim
- + (source.is_necessarily_closed() ? 1 : 2);
+ + (source.is_necessarily_closed() ? 1U : 2U);
dimension_type dest_num_rows = dest.num_rows();
diff --git a/src/Polyhedron_minimize.templates.hh b/src/Polyhedron_minimize.templates.hh
index 0516bee..63e6173 100644
--- a/src/Polyhedron_minimize.templates.hh
+++ b/src/Polyhedron_minimize.templates.hh
@@ -144,7 +144,7 @@ Polyhedron::minimize(const bool con_to_gen,
// and the 5th parameter (representing the number of lines in `dest'),
// by construction, is equal to `dest_num_rows'.
const dimension_type num_lines_or_equalities
- = conversion(source, 0, dest, tmp_sat, dest_num_rows);
+ = conversion(source, 0U, dest, tmp_sat, dest_num_rows);
// conversion() may have modified the number of rows in `dest'.
dest_num_rows = dest.num_rows();
More information about the PPL-devel
mailing list