Skip to content

Commit 804905d

Browse files
author
Daniel Kroening
committed
improve typing in binary_relation_exprt::validate
This improves type safety.
1 parent bb6baff commit 804905d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/util/std_expr.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,8 @@ class binary_predicate_exprt:public binary_exprt
775775
}
776776
};
777777

778-
/// \brief A base class for relations, i.e., binary predicates
778+
/// \brief A base class for relations, i.e., binary predicates whose
779+
/// two operands have the same type
779780
class binary_relation_exprt:public binary_predicate_exprt
780781
{
781782
public:
@@ -811,10 +812,13 @@ class binary_relation_exprt:public binary_predicate_exprt
811812
{
812813
binary_predicate_exprt::validate(expr, ns, vm);
813814

814-
// check types
815+
// we now can safely assume that 'expr' is a binary predicate
816+
const auto &expr_binary = static_cast<const binary_predicate_exprt &>(expr);
817+
818+
// check that the types of the operands are the same
815819
DATA_CHECK(
816820
vm,
817-
expr.op0().type() == expr.op1().type(),
821+
expr_binary.op0().type() == expr_binary.op1().type(),
818822
"lhs and rhs of binary relation expression should have same type");
819823
}
820824

0 commit comments

Comments
 (0)