Skip to content

Commit b8dd372

Browse files
committed
goto-symex-is-constant: treat x * sizeof(t) and sizeof(t) * x alike
Previously it would refuse and allow constant propagation respectively.
1 parent b77b5b0 commit b8dd372

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/goto-symex/goto_symex_is_constant.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@ class goto_symex_is_constantt : public is_constantt
2222
{
2323
if(expr.id() == ID_mult)
2424
{
25+
bool found_non_constant = false;
26+
2527
// propagate stuff with sizeof in it
2628
forall_operands(it, expr)
2729
{
2830
if(it->find(ID_C_c_sizeof_type).is_not_nil())
2931
return true;
3032
else if(!is_constant(*it))
31-
return false;
33+
found_non_constant = true;
3234
}
3335

34-
return true;
36+
return !found_non_constant;
3537
}
3638
else if(expr.id() == ID_with)
3739
{

unit/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ SRC += analyses/ai/ai.cpp \
2929
goto-programs/goto_trace_output.cpp \
3030
goto-programs/xml_expr.cpp \
3131
goto-symex/ssa_equation.cpp \
32+
goto-symex/is_constant.cpp \
3233
interpreter/interpreter.cpp \
3334
json/json_parser.cpp \
3435
json_symbol_table.cpp \

0 commit comments

Comments
 (0)