Repository navigation
verify: Define the difference of two null pointers as 0 - #18
Merged
Merged
Conversation
…ull pointer do not.
…s are null in ARCHITECTURE.md.
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.
C++17 [expr.add]/5 defines the difference of two null pointers as 0, but the verifier required both operands of every pointer difference to be non-null. Any contract that allows an empty range then failed:
On main this fails
pointer-differencewitha = 0, b = 0, and so does the usualq - aafter a loop that walksqfromawhenn == 0is allowed.The checks of a pointer difference (non-null operands, one origin, positions in the object) now hold when both operands are null. The value is already 0, since null is address 0. A null pointer minus a non-null one, or the reverse, still fails.
pointer_difference_fail.cppexpectednullptr - nullptrto fail, the rule this corrects; that case is nowboth_nullin the new test.Testing:
suite/pointer_difference_null.cppfails on main (same_empty,both_null,walked), and accepting either operand null instead of both letsnull_minus_objectverify andone_nullgo unresolved. Verify suite: 398 passed, 1 unsupported. A verdict differential against main over the 405 Verify sources changes onlynullptr - nullptrinpointer_difference_fail.cpp;decode_uleb128_length_11(llvm_uleb128_decoder_exhaustive.cpp) timed out on main under load in that run and verified in every other run of either binary.