From 6adf2c123ba1d1aa39d1deb758d9048e6e5f6918 Mon Sep 17 00:00:00 2001
From: Joseph Mirabel <jmirabel@laas.fr>
Date: Wed, 15 Jun 2016 17:07:50 +0200
Subject: [PATCH] Check for overflow

---
 src/graph/helper.cc | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/graph/helper.cc b/src/graph/helper.cc
index 199e71f..5cc7b0e 100644
--- a/src/graph/helper.cc
+++ b/src/graph/helper.cc
@@ -610,8 +610,15 @@ namespace hpp {
             inline nodeid_type nodeid (const GraspV_t& iG)
             {
               nodeid_type iGOH = iG[0];
-              for (index_t i = 1; i < nG; ++i)
-                iGOH += dims[i] * (iG[i]);
+              nodeid_type res;
+              for (index_t i = 1; i < nG; ++i) {
+                res = iGOH + dims[i] * (iG[i]);
+                if (res < iGOH) {
+                  hppDout (info, "Node ID overflowed. There are too many states...");
+                }
+                iGOH = res;
+                // iGOH += dims[i] * (iG[i]);
+              }
               return iGOH;
             }
 
-- 
GitLab