Skip to content

Make the simplifier preserve syntactically equal types [blocks: #2064] #3652

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

Merged
Merged
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
4 changes: 3 additions & 1 deletion src/util/simplify_expr_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,9 @@ bool simplify_exprt::simplify_concatenation(exprt &expr)
}

// { x } = x
if(expr.operands().size()==1)
if(
expr.operands().size() == 1 &&
base_type_eq(expr.op0().type(), expr.type(), ns))
{
exprt tmp;
tmp.swap(expr.op0());
Expand Down
7 changes: 7 additions & 0 deletions src/util/simplify_expr_struct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Author: Daniel Kroening, [email protected]
#include "arith_tools.h"
#include "base_type.h"
#include "byte_operators.h"
#include "invariant.h"
#include "namespace.h"
#include "pointer_offset_size.h"
#include "std_expr.h"
Expand Down Expand Up @@ -45,6 +46,9 @@ bool simplify_exprt::simplify_member(exprt &expr)
if(op1.get(ID_component_name)==component_name)
{
// found it!
DATA_INVARIANT(
base_type_eq(op2.type(), expr.type(), ns),
"member expression type must match component type");
exprt tmp;
tmp.swap(op2);
expr.swap(tmp);
Expand Down Expand Up @@ -134,6 +138,9 @@ bool simplify_exprt::simplify_member(exprt &expr)
if(struct_type.has_component(component_name))
{
std::size_t number=struct_type.component_number(component_name);
DATA_INVARIANT(
base_type_eq(op.operands()[number].type(), expr.type(), ns),
"member expression type must match component type");
exprt tmp;
tmp.swap(op.operands()[number]);
expr.swap(tmp);
Expand Down