diff --git a/src/goto-symex/symex_assign.cpp b/src/goto-symex/symex_assign.cpp index 846bb2c6b0c..c8da70d93ea 100644 --- a/src/goto-symex/symex_assign.cpp +++ b/src/goto-symex/symex_assign.cpp @@ -28,6 +28,8 @@ void goto_symext::symex_assign( exprt lhs=code.lhs(); exprt rhs=code.rhs(); + DATA_INVARIANT(lhs.type() == rhs.type(), "assignments must be type consistent"); + clean_expr(lhs, state, true); clean_expr(rhs, state, false); diff --git a/src/util/expr_initializer.cpp b/src/util/expr_initializer.cpp index 6402a7edf5a..3112883b33e 100644 --- a/src/util/expr_initializer.cpp +++ b/src/util/expr_initializer.cpp @@ -270,10 +270,13 @@ exprt expr_initializert::expr_initializer_rec( } else if(type_id==ID_c_enum_tag) { - return - expr_initializer_rec( - ns.follow_tag(to_c_enum_tag_type(type)), - source_location); + exprt result = expr_initializer_rec( + ns.follow_tag(to_c_enum_tag_type(type)), source_location); + + // use the tag type + result.type() = type; + + return result; } else if(type_id==ID_struct_tag) {