nodestack: re-insert falsely-declared "dead code"
authorBrian Norris <banorris@uci.edu>
Tue, 17 Jul 2012 05:44:40 +0000 (22:44 -0700)
committerBrian Norris <banorris@uci.edu>
Tue, 17 Jul 2012 05:48:31 +0000 (22:48 -0700)
"remove dead code...  loop entrance condition is i<backtrack.size().  Therefore,
this branch can never be taken."

False.

While the entrance condition prevents 'i == backtrack.size()', the loop may
exit with 'i == backtrack.size()', since i++ is executed after the last
iteration. Since we do not expect or want this condition to occur, though, I
transform this to a documented ASSERT().

nodestack.cc

index 131452d..aa3a6c9 100644 (file)
@@ -109,6 +109,9 @@ thread_id_t Node::get_next_backtrack()
        for (i = 0; i < backtrack.size(); i++)
                if (backtrack[i] == true)
                        break;
+       /* Backtrack set was empty? */
+       ASSERT(i != backtrack.size());
+
        backtrack[i] = false;
        numBacktracks--;
        return int_to_id(i);