
Module: ppl/ppl Branch: master Commit: 9afcaffceb21f412fe286e06bb438a8cc78b7dd6 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=9afcaffceb21f...
Author: Enea Zaffanella zaffanella@cs.unipr.it Date: Wed Feb 22 21:48:20 2012 +0100
Avoid implicit conversions changing integer type signedness. Detected by ECLAIR service utypflag.
---
src/CO_Tree.cc | 13 ++++++++----- src/CO_Tree.inlines.hh | 5 +++-- src/CO_Tree.templates.hh | 5 +++-- 3 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/src/CO_Tree.cc b/src/CO_Tree.cc index 94cd7f5..45913e0 100644 --- a/src/CO_Tree.cc +++ b/src/CO_Tree.cc @@ -893,7 +893,8 @@ PPL::CO_Tree --subtree_size; }
- return first_unused_index - indexes; + PPL_ASSERT(first_unused_index >= indexes); + return static_cast<dimension_type>(first_unused_index - indexes); }
void @@ -911,8 +912,9 @@ PPL::CO_Tree::redistribute_elements_in_subtree( // For each node level, the stack may contain up to two element (one for the // subtree rooted at the right son of a node of that level, and one for the // node itself). An additional element can be at the top of the tree. - static std::pair<dimension_type,dimension_type> - stack[2*CHAR_BIT*sizeof(dimension_type)+1]; + static const unsigned stack_size + = 2U * static_cast<unsigned>(CHAR_BIT) * sizeof(dimension_type) + 1U; + static std::pair<dimension_type,dimension_type> stack[stack_size];
std::pair<dimension_type,dimension_type>* stack_first_empty = stack;
@@ -1003,8 +1005,9 @@ PPL::CO_Tree::move_data_from(CO_Tree& tree) { // with operation 0, one element with operation 2 and one element // with operation 3. An additional element with operation 1 can be at the // top of the tree. - static std::pair<dimension_type, signed char> - stack[5*CHAR_BIT*sizeof(dimension_type)]; + static const unsigned stack_size + = 5U * static_cast<unsigned>(CHAR_BIT) * sizeof(dimension_type); + static std::pair<dimension_type, signed char> stack[stack_size];
dimension_type stack_first_empty = 0;
diff --git a/src/CO_Tree.inlines.hh b/src/CO_Tree.inlines.hh index 50a03e7..48b76fc 100644 --- a/src/CO_Tree.inlines.hh +++ b/src/CO_Tree.inlines.hh @@ -761,7 +761,8 @@ CO_Tree::tree_iterator::follow_left_children_with_value() { p -= (offset - 1); while (*p == unused_index) ++p; - i = p - tree.indexes; + PPL_ASSERT(p >= tree.indexes); + i = static_cast<dimension_type>(p - tree.indexes); offset = i & -i; PPL_ASSERT(OK()); } @@ -774,7 +775,7 @@ CO_Tree::tree_iterator::follow_right_children_with_value() { p += (offset - 1); while (*p == unused_index) --p; - i = p - tree.indexes; + i = static_cast<dimension_type>(p - tree.indexes); offset = i & -i; PPL_ASSERT(OK()); } diff --git a/src/CO_Tree.templates.hh b/src/CO_Tree.templates.hh index 488f541..7c8e5ac 100644 --- a/src/CO_Tree.templates.hh +++ b/src/CO_Tree.templates.hh @@ -53,8 +53,9 @@ CO_Tree::CO_Tree(Iterator i, dimension_type n) { // with operation 0, one element with operation 2 and one element // with operation 3. An additional element with operation 1 can be at the // top of the tree. - static std::pair<dimension_type, signed char> - stack[4*CHAR_BIT*sizeof(dimension_type)+1]; + static const unsigned stack_size + = 4U * static_cast<unsigned>(CHAR_BIT) * sizeof(dimension_type) + 1U; + static std::pair<dimension_type, signed char> stack[stack_size];
dimension_type stack_first_empty = 0;