Open etiennebirling opened 1 month ago
Note that this also seems to occur when reversing the polarity
This crash occurs because we ignore Viper's checks that happen after parsing. In your output log you can see the line:
[WARN] Quantified arguments can only be used directly (vercors-267072219603548256.sil@238.31--238.70)
Which notifies us of the actual problem which is that you can only put a direct expression in between \in
and ;
.
If I'm understanding correctly what you're trying to do, you could write this as:
\polarity_dependent(true, (\forperm struct f r \in r.cac; r != *this));
Note that this will stop working in a future version of VerCors since the way we encode C structs has changed quite a lot. (and I didn't consider the use of forperm
with C structs while making these changes)
Thanks for your answer. Do you call the value this a direct expression because it refers to an argument? I tried to replace it with r as you suggested but the thing still crashes (same bug report).
Regarding the formula itself, no I think you did not get correctly what I mean. What I am trying to phrase is "No permission to any cac field of a struct t instance is held" (meaning no permission overall, not just forbidding to hold the cac field of this specifically). That is not what your suggested formula describes, right?
I'm not 100% sure what they mean by direct expression in Viper but I guess basically anything of the form a.b
is a direct expression of a
, but most other things (such as the pointer dereferences that happen in your example) aren't.
I guess because the only things with a field cac
will be the struct f you could just do \forperm struct f r \in r.cac; false
. (note if there are multiple structs with fields with the name cac
this will still work since VerCors will give them different names internally)
Ok, I understand. You suggestion worked to fix the problem. Thanks for the help.
Crash Message
Version Information
2.2.0
HEAD
(changes=false)Arguments
forperm.c
File Inputs
forperm.c
```c struct t {int val;}; struct f {int cac;}; /*@ requires \pointer(this, 10, write); requires Perm(this->val, 1); ensures \pointer(this, 10, write); ensures \polarity_dependent(true, (\forperm struct f * this \in this->cac; false)); ensures Perm(this->val, 1); @*/ void incr(struct t* this, int n) { this->val = this->val + n; } ```Full Log