-
Notifications
You must be signed in to change notification settings - Fork 279
Do not use side_effect_expr_nondett in recursive_initialization #5409
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
Do not use side_effect_expr_nondett in recursive_initialization #5409
Conversation
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.
There are a bunch of changes - it'd be good to have a test for each one to ensure the change has worked as expected. Other than that, lgtm
test.c | ||
--function test_function --harness-type call-function | ||
\[test_function\.assertion\.1\] line \d+ assertion test != 42 | ||
^EXIT=10$ |
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.
⛏️ It'd be good to have a positive regex for what it now contains (e.g. a declaration or whatever) since that documents the behaviour, and makes the test less likely to spuriously pass in the future
If we use side_effect_expr_nondett then dump_c will generation function calls | ||
to functions with names like nondet_signed_int without declaration. | ||
This can cause problems around usability. | ||
|
||
To fix this, we changed goto-harness to just not use side_effect_expr_nondett | ||
at all. | ||
|
||
This test tests for the absence the use for these things. |
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 seems like great info for a commit message (since it is talking about why we moved from one solution to another) but in a test, where the reader won't have the context that we used to use side_effect_expr_nondett
it is maybe confusing. I'd focus instead on what the test is testing - in this case not using undeclared functions.
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 note this info is in the commit too 👍 I still think probably more confusing than helpful in the test, but up to you
@@ -169,11 +169,11 @@ void recursive_initializationt::initialize( | |||
goto_model.symbol_table.lookup_ref(fun_name); | |||
const auto proper_init_case = code_function_callt{ | |||
fun_symbol.symbol_expr(), {depth, address_of_exprt{lhs}}}; | |||
|
|||
const auto should_make_equal = |
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 like this is a separate case and therefore should have a separate test? 🧷
@@ -693,9 +693,12 @@ code_blockt recursive_initializationt::build_pointer_constructor( | |||
code_blockt null_and_return{{assign_null, code_returnt{}}}; | |||
body.add(code_ifthenelset{conjunction(should_not_recurse), null_and_return}); | |||
|
|||
const auto should_recurse_nondet = |
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.
🚫 🧷
@@ -753,8 +756,10 @@ code_blockt recursive_initializationt::build_array_string_constructor( | |||
{ | |||
index_exprt index_expr{dereference_exprt{result}, | |||
from_integer(index, size_type())}; | |||
body.add(code_assignt{ |
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.
🚫 🧷
@@ -1029,10 +1035,6 @@ code_blockt recursive_initializationt::build_function_pointer_constructor( | |||
const auto function_pointer_selector = | |||
get_fresh_local_symexpr("function_pointer_selector"); | |||
body.add(code_declt{function_pointer_selector}); | |||
body.add( |
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.
🧷
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.
Ehem, upon trying to come up with a test for this I actually found that there was a mess up in some earlier refactoring leading to this function never ever getting called (instead implementation of what this used to do has been moved into build_dynamic_array_constructor
.
That is a tad unfortunate. I will add a commit that removes this function to show that it doesn’t work right now, and then we can re-refactor it later if we like.
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.
Good enough for me, can we have a ticket for the better long term fix?
Codecov Report
@@ Coverage Diff @@
## develop #5409 +/- ##
========================================
Coverage 68.19% 68.19%
========================================
Files 1175 1175
Lines 97497 97478 -19
========================================
- Hits 66484 66479 -5
+ Misses 31013 30999 -14
Continue to review full report at Codecov.
|
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.
Fine modulo @thk123 's comments.
07dec16
to
8bc1772
Compare
If we use side_effect_expr_nondett then dump_c will generation function calls to functions with names like `nondet_int` without declaration. This is a problem because it’ll lead the C frontend to complain about undeclared identifiers and such. To fix this, we changed goto-harness to just not use side_effect_expr_nondett at all (better long term fix would be to make sure `dump_c` outputs declarations too).
The ::build_array_string_constructor method was originally intended to be used for building C string constructors. Unfortunately as written the condition for calling it was actually impossible to satisfy. This wasn’t noticed so far because similar code is now generated in ::build_dynamic_array_constructor instead. Dead code is a maintenance burden so it’s removed here.
8bc1772
to
430ab00
Compare
Note that there’s a second commit removing a dead (as in, impossible to reach) function now. |
If we use side_effect_expr_nondett then dump_c will generation function calls
to functions with names like
nondet_int
without declaration.This is a problem because it’ll lead the C frontend to complain about
undeclared identifiers and such.
To fix this, we changed goto-harness to just not use side_effect_expr_nondett
at all (better long term fix would be to make sure
dump_c
outputsdeclarations too).