Skip to content

Commit 7c67b23

Browse files
authored
Merge pull request diffblue#2110 from tautschnig/type-mismatch-exception
Use improved reporting for equality-without-matching-types
2 parents 18fb262 + 808dade commit 7c67b23

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

src/cbmc/bmc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -693,10 +693,10 @@ int bmct::do_language_agnostic_bmc(
693693
message.error() << error_msg << message.eom;
694694
return CPROVER_EXIT_EXCEPTION;
695695
}
696-
catch(...)
696+
catch(std::runtime_error &e)
697697
{
698-
message.error() << "unable to get solver" << message.eom;
699-
throw std::current_exception();
698+
message.error() << e.what() << message.eom;
699+
return CPROVER_EXIT_EXCEPTION;
700700
}
701701

702702
switch(final_result)

src/goto-symex/symex_target_equation.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -523,10 +523,19 @@ void symex_target_equationt::convert_constraints(
523523
{
524524
if(step.is_constraint())
525525
{
526-
if(step.ignore)
527-
continue;
528-
529-
decision_procedure.set_to_true(step.cond_expr);
526+
if(!step.ignore)
527+
{
528+
try
529+
{
530+
decision_procedure.set_to_true(step.cond_expr);
531+
}
532+
catch(const bitvector_conversion_exceptiont &conversion_exception)
533+
{
534+
util_throw_with_nested(
535+
equation_conversion_exceptiont(
536+
"Error converting constraints for step", step));
537+
}
538+
}
530539
}
531540
}
532541
}

src/solvers/flattening/boolbv_equality.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,20 @@ Author: Daniel Kroening, [email protected]
1212
#include <util/base_type.h>
1313
#include <util/invariant.h>
1414

15+
#include "bv_conversion_exceptions.h"
1516
#include "flatten_byte_operators.h"
1617

1718
literalt boolbvt::convert_equality(const equal_exprt &expr)
1819
{
1920
const bool is_base_type_eq =
2021
base_type_eq(expr.lhs().type(), expr.rhs().type(), ns);
21-
DATA_INVARIANT(
22-
is_base_type_eq,
23-
std::string("equality without matching types:\n") + "######### lhs: " +
24-
expr.lhs().pretty() + '\n' + "######### rhs: " + expr.rhs().pretty());
22+
if(!is_base_type_eq)
23+
{
24+
const std::string error_msg =
25+
std::string("equality without matching types:\n") + "######### lhs: " +
26+
expr.lhs().pretty() + '\n' + "######### rhs: " + expr.rhs().pretty();
27+
throw bitvector_conversion_exceptiont(error_msg, expr);
28+
}
2529

2630
// see if it is an unbounded array
2731
if(is_unbounded_array(expr.lhs().type()))

0 commit comments

Comments
 (0)