Skip to content

Commit 902fec4

Browse files
authored
Merge pull request #4350 from romainbrenguier/bugfix/bdd-var-type
Fix type of bddVar argument
2 parents 9468913 + d495995 commit 902fec4

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/solvers/bdd/bdd_cudd.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ class bdd_nodet
3535
return Cudd_IsComplement(node) != 0;
3636
}
3737

38+
/// Type of indexes of Boolean variables
39+
using indext = int;
40+
3841
/// Label on the node, corresponds to the index of a Boolean variable
39-
std::size_t index() const
42+
indext index() const
4043
{
4144
return Cudd_NodeReadIndex(node);
4245
}
@@ -147,7 +150,7 @@ class bdd_managert
147150
return bddt(cudd.bddZero());
148151
}
149152

150-
bddt bdd_variable(std::size_t index)
153+
bddt bdd_variable(bdd_nodet::indext index)
151154
{
152155
return bddt(cudd.bddVar(index));
153156
}

src/solvers/bdd/bdd_miniBDD.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ class bdd_nodet
3939
return node->node_number == 0;
4040
}
4141

42+
/// Type of indexes of Boolean variables
43+
using indext = std::size_t;
44+
4245
/// Label on the node, corresponds to the index of a Boolean variable
43-
std::size_t index() const
46+
indext index() const
4447
{
4548
return bdd_var_to_index.at(node->var);
4649
}
@@ -158,7 +161,7 @@ class bdd_managert : private mini_bdd_mgrt
158161
return bddt(False());
159162
}
160163

161-
bddt bdd_variable(std::size_t index)
164+
bddt bdd_variable(bdd_nodet::indext index)
162165
{
163166
auto it = index_to_bdd.find(index);
164167
if(it != index_to_bdd.end())

src/solvers/prop/bdd_expr.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Author: Michael Tautschnig, [email protected]
1111

1212
#include "bdd_expr.h"
1313

14+
#include <util/arith_tools.h>
1415
#include <util/expr_util.h>
1516
#include <util/format_expr.h>
1617
#include <util/invariant.h>
@@ -111,8 +112,9 @@ exprt bdd_exprt::as_expr(
111112
return true_exprt();
112113
}
113114

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

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

0 commit comments

Comments
 (0)