-
Notifications
You must be signed in to change notification settings - Fork 274
check for side effects in quantifiers #2979
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
Conversation
@@ -93,8 +93,6 @@ bool goto_convertt::needs_cleaning(const exprt &expr) | |||
// g1 = (i == 0) | |||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment above this code needs to be moved, it doesn't actually make sense when these lines are removed.
@@ -409,7 +407,7 @@ void goto_convertt::clean_expr( | |||
// check if there are side-effects | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invariant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to simplify as described below.
src/ansi-c/c_typecheck_expr.cpp
Outdated
@@ -166,6 +166,18 @@ bool c_typecheck_baset::gcc_types_compatible_p( | |||
return false; | |||
} | |||
|
|||
static bool has_side_effect(const exprt &expr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need - see below.
src/ansi-c/c_typecheck_expr.cpp
Outdated
@@ -303,6 +315,13 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr) | |||
throw 0; | |||
} | |||
|
|||
if(has_side_effect(expr.op1())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DATA_INVARIANT(!has_subexpr(expr, ID_side_effect), "the front-end should check quantified expressions for side-effects");
0812cc1
to
f505207
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line got too long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.