check for side effects in quantifiers#2979
Conversation
| // g2 = (i > 10) | ||
| // forall (i : int) (g1 || g2) | ||
| if(expr.id()==ID_forall || expr.id()==ID_exists) | ||
| return false; |
There was a problem hiding this comment.
The comment above this code needs to be moved, it doesn't actually make sense when these lines are removed.
| goto_programt tmp; | ||
| clean_expr(expr.op1(), tmp, mode, true); | ||
| if(tmp.instructions.empty()) | ||
| if(!tmp.instructions.empty()) |
There was a problem hiding this comment.
So this was dead code before. It's no longer dead code now - do we have any tests exercising it?
cc4fae7 to
a887387
Compare
|
Now with different approach -- the rule is now checked in the front-end |
a887387 to
0812cc1
Compare
allredj
left a comment
There was a problem hiding this comment.
Passed Diffblue compatibility checks (cbmc commit: 0812cc1).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85673814
| throw 0; | ||
| } | ||
| return; | ||
| // the front-end checks these for side-effects |
There was a problem hiding this comment.
DATA_INVARIANT(!has_subexpr(expr, ID_side_effect), "the front-end should check quantified expressions for side-effects");
tautschnig
left a comment
There was a problem hiding this comment.
I'd suggest to simplify as described below.
src/ansi-c/c_typecheck_expr.cpp
Outdated
| return false; | ||
| } | ||
|
|
||
| static bool has_side_effect(const exprt &expr) |
src/ansi-c/c_typecheck_expr.cpp
Outdated
| throw 0; | ||
| } | ||
|
|
||
| if(has_side_effect(expr.op1())) |
There was a problem hiding this comment.
if(has_subexpr(expr.op1(), ID_side_effect))
| throw 0; | ||
| } | ||
| return; | ||
| // the front-end checks these for side-effects |
There was a problem hiding this comment.
DATA_INVARIANT(!has_subexpr(expr, ID_side_effect), "the front-end should check quantified expressions for side-effects");
0812cc1 to
f505207
Compare
tautschnig
left a comment
There was a problem hiding this comment.
Looks good, except for the line break.
| throw 0; | ||
| } | ||
| return; | ||
| DATA_INVARIANT(!has_subexpr(expr, ID_side_effect), "the front-end should check quantified expressions for side-effects"); |
There was a problem hiding this comment.
This line got too long.
allredj
left a comment
There was a problem hiding this comment.
Passed Diffblue compatibility checks (cbmc commit: f505207).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85988064
This fixes a failed attempt to check for quantifiers during goto conversion by checking earlier in the C front-end.
f505207 to
a3fa911
Compare
allredj
left a comment
There was a problem hiding this comment.
Passed Diffblue compatibility checks (cbmc commit: a3fa911).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/86019720
Uh oh!
There was an error while loading. Please reload this page.