[PPL-devel] [GIT] ppl/ppl(master): Bug in Grid::wrap_assign() fixed.

Patricia Hill p.m.hill at leeds.ac.uk
Thu Mar 25 08:16:25 CET 2010


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

Author: Patricia Hill <p.m.hill at leeds.ac.uk>
Date:   Thu Mar 25 07:14:40 2010 +0000

Bug in Grid::wrap_assign() fixed.
Test that showed the bug added to wrap1.cc.

---

 src/Grid_public.cc  |    2 +-
 tests/Grid/wrap1.cc |   29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/src/Grid_public.cc b/src/Grid_public.cc
index 4040995..ad89369 100644
--- a/src/Grid_public.cc
+++ b/src/Grid_public.cc
@@ -2685,7 +2685,7 @@ PPL::Grid::wrap_assign(const Variables_Set& vars,
   // Dimension-compatibility check of `*pcs', if any.
   if (pcs != 0) {
    const dimension_type pcs_space_dim  = pcs->space_dimension();
-   if (pcs->space_dimension() != space_dim)
+   if (pcs->space_dimension() > space_dim)
      throw_dimension_incompatible("wrap_assign(vs, ...)", pcs_space_dim);
   }
 
diff --git a/tests/Grid/wrap1.cc b/tests/Grid/wrap1.cc
index 2c14a43..f123da6 100644
--- a/tests/Grid/wrap1.cc
+++ b/tests/Grid/wrap1.cc
@@ -509,6 +509,34 @@ test19() {
   return ok;
 }
 
+bool
+test20() {
+  Variable x(0);
+  Variable y(1);
+  Variable z(2);
+  Variable w(3);
+
+  Grid gr(4);
+  gr.add_congruence((x %= 1) / 2);
+
+  Constraint_System pcs;
+  pcs.insert(x+y == 2);
+
+  Variables_Set vars(x, w);
+
+  // The constraint system pcs will be ignored.
+  gr.wrap_assign(vars, BITS_8, UNSIGNED, OVERFLOW_WRAPS, &pcs);
+
+  Grid known_result(4);
+  known_result.add_congruence((x %= 1) / 2);
+
+  bool ok = (gr == known_result);
+
+  print_congruences(gr, "*** gr.wrap_assign(...) ***");
+
+  return ok;
+}
+
 } // namespace
 
 BEGIN_MAIN
@@ -531,4 +559,5 @@ BEGIN_MAIN
   DO_TEST_F8(test17);
   DO_TEST_F8(test18);
   DO_TEST_F8(test19);
+  DO_TEST_F8(test20);
 END_MAIN




More information about the PPL-devel mailing list