Repository navigation
verify: Reject valid(p, n) outside a precondition - #40
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
valid(p, n)declares an extent only as a top-level condition of a precondition, where memory checking reads it. Anywhere else it lowered to its builtin spec, whose body istrue, so a claim made with it held without meaning anything. On 0.1.1 and main this verifies:The change: under
--check-ub,misplacedValidMarker(Transform/UBChecks.cpp) looks for the marker everywhere else a function may state a condition: postconditions, recommends, decreases,cppverify::when, the proof blocks of a spec's clauses, loop invariants, measures, and footprints,cppverify::check, assumptions, and ghost code. It also checks spec functions, whose bodiesinstrumentUBChecksdoes not visit. A marker found there is an error for that function, which is then not verified; the other functions of the file still are:The message ends with the place: a postcondition, a loop invariant, a
cppverify::check, ghost code, or a spec function. A user-declared spec namedvalidis the same marker and gets the same check. With--no-check-ubevery marker already folds totruewith a warning, and none is an error.Docs:
Testing:
Verify/suite/valid_outside_precondition.cppcovers a marker in a postcondition, a loop invariant, acppverify::check, ghost code, and a spec function, each an error naming its place. A function that uses the marker correctly still verifies, and under--no-check-ubthe warning appears andin_postverifies. It fails on main. Each of five mutations fails it: not checking postconditions, loop invariants,cppverify::check, ghost code, or spec functions. The documentation's rejected example also fails against main's binary, which accepts it.Checked: Verify suite 424 passed, 1 unsupported; VerifyTests 60 passed, 1 skipped (encoding parity, which needs archives). A verdict differential against main over 432 Verify sources changes only the new test. After the rebase onto #39, every documentation example passes (175) and the site builds with
-W.