Conversation
Member
|
Oh btw Edoardo and I are working on proving that all the VerCors ADTs are consistent and we found that the const_pointer one isn't. I.e. writing |
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.
PR description
I think I made a mistake when introducing a sequence encoding for const pointers. Const pointers are references to which you cannot write towards that reference. However other parts of the program might have a reference towards that pointer, to which it eventually can write again. This is not possible with the current encoding to sequences, since once it is turned to a sequence, it cannot be turned back.
For example
Would never be possible with the current encoding. And is I think some use case we want to support.
So I think the better name is an immutable pointer. I.e. a pointer, after which its contents are initialized, are guaranteed to never change again.
So for this we introduce an extra annotation named
immutablewhich captures this. This really is to old encoding for const pointers, so mostly this PR is renaming everything.To get the old behaviour for const pointers write this now instead:
const /*@immutable*/int* xs`.Note: I think it is possible to have a better encoding for const pointers: you still make the underlying pointer block a sequence, but this sequence is saved in a field in Viper, so you need permission for this complete sequence. This means you do permission bookkeeping for the complete pointer block, which is still cheaper since its not a permission qualifier.
This fixes the given example above, since if we give the permission of
const int* xsto some other thread that does not finish, we do not allow the const pointer to be coerced back to a normal pointer when calling f in main. We can only safely coerce back, if we have the permission.