File tree Expand file tree Collapse file tree 4 files changed +37
-4
lines changed Expand file tree Collapse file tree 4 files changed +37
-4
lines changed Original file line number Diff line number Diff line change 1- FUTURE
1+ KNOWNBUG
22main.c
33--constants --verify
44^EXIT=0$
55^SIGNAL=0$
66^\[main.assertion.1\] file main.c line 11 function main, assertion tmp_if_expr: SUCCESS$
7- ^\[main.assertion.2\] file main.c line 12 function main, assertion tmp_if_expr\$1 : FAILURE$
7+ ^\[main.assertion.2\] file main.c line 12 function main, assertion tmp_if_expr\$0 : FAILURE \(if reachable\) $
88--
99^warning: ignoring
Original file line number Diff line number Diff line change 1+ #include <assert.h>
2+
3+ int main ()
4+ {
5+ int i = 1 ;
6+ int * p = & i ;
7+ assert (* p == 1 );
8+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ main.c
3+ --constants --verify
4+ ^EXIT=0$
5+ ^SIGNAL=0$
6+ ^\[main.assertion.1\] file main.c line 7 function main, assertion \*p == 1: SUCCESS$
7+ --
8+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -576,8 +576,25 @@ bool constant_propagator_domaint::replace_constants_and_simplify(
576576 exprt &expr,
577577 const namespacet &ns)
578578{
579- bool did_not_change_anything = known_values.replace_const .replace (expr);
580- did_not_change_anything &= simplify (expr, ns);
579+ bool did_not_change_anything = true ;
580+
581+ // iterate constant propagation and simplification until we cannot
582+ // constant-propagate any further - a prime example is pointer dereferencing,
583+ // where constant propagation may have a value of the pointer, the simplifier
584+ // takes care of evaluating dereferencing, and we might then have the value of
585+ // the resulting symbol known to constant propagation and thus replace the
586+ // dereferenced expression by a constant
587+ while (!known_values.replace_const .replace (expr))
588+ {
589+ did_not_change_anything = false ;
590+ simplify (expr, ns);
591+ }
592+
593+ // even if we haven't been able to constant-propagate anything, run the
594+ // simplifier on the expression
595+ if (did_not_change_anything)
596+ did_not_change_anything &= simplify (expr, ns);
597+
581598 return did_not_change_anything;
582599}
583600
You can’t perform that action at this time.
0 commit comments