Skip to content

Fix type of bddVar argument #4350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/solvers/bdd/bdd_cudd.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ class bdd_nodet
return Cudd_IsComplement(node) != 0;
}

/// Type of indexes of Boolean variables
using indext = int;

/// Label on the node, corresponds to the index of a Boolean variable
std::size_t index() const
indext index() const
{
return Cudd_NodeReadIndex(node);
}
Expand Down Expand Up @@ -147,7 +150,7 @@ class bdd_managert
return bddt(cudd.bddZero());
}

bddt bdd_variable(std::size_t index)
bddt bdd_variable(bdd_nodet::indext index)
{
return bddt(cudd.bddVar(index));
}
Expand Down
7 changes: 5 additions & 2 deletions src/solvers/bdd/bdd_miniBDD.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ class bdd_nodet
return node->node_number == 0;
}

/// Type of indexes of Boolean variables
using indext = std::size_t;

/// Label on the node, corresponds to the index of a Boolean variable
std::size_t index() const
indext index() const
{
return bdd_var_to_index.at(node->var);
}
Expand Down Expand Up @@ -158,7 +161,7 @@ class bdd_managert : private mini_bdd_mgrt
return bddt(False());
}

bddt bdd_variable(std::size_t index)
bddt bdd_variable(bdd_nodet::indext index)
{
auto it = index_to_bdd.find(index);
if(it != index_to_bdd.end())
Expand Down
6 changes: 4 additions & 2 deletions src/solvers/prop/bdd_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Author: Michael Tautschnig, [email protected]

#include "bdd_expr.h"

#include <util/arith_tools.h>
#include <util/expr_util.h>
#include <util/format_expr.h>
#include <util/invariant.h>
Expand Down Expand Up @@ -111,8 +112,9 @@ exprt bdd_exprt::as_expr(
return true_exprt();
}

INVARIANT(r.index() < node_map.size(), "Index should be in node_map");
const exprt &n_expr = node_map[r.index()];
auto index = numeric_cast_v<std::size_t>(r.index());
INVARIANT(index < node_map.size(), "Index should be in node_map");
const exprt &n_expr = node_map[index];

// Look-up cache for already computed value
auto insert_result = cache.emplace(r.id(), nil_exprt());
Expand Down