Skip to content

Assignment type consistency #3634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/goto-symex/symex_assign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
11 changes: 7 additions & 4 deletions src/util/expr_initializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,13 @@ exprt expr_initializert<nondet>::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)
{
Expand Down