Skip to content

Fix evaluation of decreases clause #6269

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

Merged
merged 2 commits into from
Aug 4, 2021

Conversation

SaswatPadhi
Copy link
Contributor

__CPROVER_decreases clauses on loops were evaluated outside of loop iterations, which was buggy. In this PR, we fix this behavior: decreases clause is evaluated inside the loop block (after the loop guard is satisfied).

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@SaswatPadhi SaswatPadhi added bugfix aws Bugs or features of importance to AWS CBMC users Code Contracts Function and loop contracts labels Aug 4, 2021
@SaswatPadhi SaswatPadhi self-assigned this Aug 4, 2021
@codecov
Copy link

codecov bot commented Aug 4, 2021

Codecov Report

Merging #6269 (dbb5163) into develop (4844d22) will decrease coverage by 0.27%.
The diff coverage is 94.26%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #6269      +/-   ##
===========================================
- Coverage    76.17%   75.90%   -0.28%     
===========================================
  Files         1484     1492       +8     
  Lines       162317   162724     +407     
===========================================
- Hits        123646   123513     -133     
- Misses       38671    39211     +540     
Impacted Files Coverage Δ
src/ansi-c/expr2c_class.h 100.00% <ø> (ø)
src/goto-instrument/contracts/contracts.h 100.00% <ø> (ø)
src/goto-instrument/contracts/contracts.cpp 92.82% <90.90%> (+0.98%) ⬆️
src/ansi-c/expr2c.cpp 65.60% <94.87%> (+0.65%) ⬆️
unit/ansi-c/expr2c.cpp 100.00% <100.00%> (ø)
src/util/find_symbols.h 0.00% <0.00%> (-100.00%) ⬇️
src/goto-instrument/accelerate/path.h 0.00% <0.00%> (-100.00%) ⬇️
src/goto-instrument/accelerate/polynomial.h 0.00% <0.00%> (-100.00%) ⬇️
...o-instrument/accelerate/polynomial_accelerator.cpp 0.00% <0.00%> (-78.13%) ⬇️
src/util/parse_options.h 50.00% <0.00%> (-50.00%) ⬇️
... and 42 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e6f6970...dbb5163. Read the comment docs.

Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like an appropriate fix. Thanks for separating out the refactor into it's own commit; that does make reviewing easier.

@SaswatPadhi
Copy link
Contributor Author

Thanks for taking a look @martin-cs.
I realized that some of the refactoring (renaming) changes had spilled into the next commit, so I fixed that.

@feliperodri could you please take a look too?

Copy link
Collaborator

@feliperodri feliperodri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only minor changes.

`__CPROVER_decreases` clauses on loops were evaluated outside of loop
iterations (before checking the loop guard), which was buggy.
We fix this behavior in this commit. The clause is now evaluated inside
the loop block (after the loop guard is satisfied).
@SaswatPadhi SaswatPadhi merged commit 3ebacfe into diffblue:develop Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws Bugs or features of importance to AWS CBMC users bugfix Code Contracts Function and loop contracts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants