Skip to content

Commit

Permalink
Merge pull request #2110 from tautschnig/type-mismatch-exception
Browse files Browse the repository at this point in the history
Use improved reporting for equality-without-matching-types
  • Loading branch information
tautschnig authored May 17, 2018
2 parents 18fb262 + 808dade commit 7c67b23
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/cbmc/bmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,10 +693,10 @@ int bmct::do_language_agnostic_bmc(
message.error() << error_msg << message.eom;
return CPROVER_EXIT_EXCEPTION;
}
catch(...)
catch(std::runtime_error &e)
{
message.error() << "unable to get solver" << message.eom;
throw std::current_exception();
message.error() << e.what() << message.eom;
return CPROVER_EXIT_EXCEPTION;
}

switch(final_result)
Expand Down
17 changes: 13 additions & 4 deletions src/goto-symex/symex_target_equation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,19 @@ void symex_target_equationt::convert_constraints(
{
if(step.is_constraint())
{
if(step.ignore)
continue;

decision_procedure.set_to_true(step.cond_expr);
if(!step.ignore)
{
try
{
decision_procedure.set_to_true(step.cond_expr);
}
catch(const bitvector_conversion_exceptiont &conversion_exception)
{
util_throw_with_nested(
equation_conversion_exceptiont(
"Error converting constraints for step", step));
}
}
}
}
}
Expand Down
12 changes: 8 additions & 4 deletions src/solvers/flattening/boolbv_equality.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@ Author: Daniel Kroening, [email protected]
#include <util/base_type.h>
#include <util/invariant.h>

#include "bv_conversion_exceptions.h"
#include "flatten_byte_operators.h"

literalt boolbvt::convert_equality(const equal_exprt &expr)
{
const bool is_base_type_eq =
base_type_eq(expr.lhs().type(), expr.rhs().type(), ns);
DATA_INVARIANT(
is_base_type_eq,
std::string("equality without matching types:\n") + "######### lhs: " +
expr.lhs().pretty() + '\n' + "######### rhs: " + expr.rhs().pretty());
if(!is_base_type_eq)
{
const std::string error_msg =
std::string("equality without matching types:\n") + "######### lhs: " +
expr.lhs().pretty() + '\n' + "######### rhs: " + expr.rhs().pretty();
throw bitvector_conversion_exceptiont(error_msg, expr);
}

// see if it is an unbounded array
if(is_unbounded_array(expr.lhs().type()))
Expand Down

0 comments on commit 7c67b23

Please sign in to comment.