Closed jennalwise closed 1 year ago
Same error pops up in stack-list.c0
where \result
is used in a logical conditional run-time check:
bool isEmpty(struct Stack* s)
//@requires ?;
//@ensures ? && (\result == true ? true : nonEmptyStack(s));
{
if (s == NULL)
{
return true;
}
else
{
if (s->top == NULL)
{
return true;
}
else
{
return false;
}
}
}
Some more information from debugging:
RuntimeCheck(MethodPost,FieldSeparationCheck(Field(Result,MinPriorityQueue,size)),None)
containing result in conditionsRuntimeCheck(MethodPost,FieldAccessibilityCheck(Field(Var(q),MinPriorityQueue,size)),None)
This happens similarly in the second example.
It turns out all the checks are not marked as conditions except for the last one:
[OKAY] RuntimeCheck(MethodPost,FieldAccessibilityCheck(Field(Var(q),MinPriorityQueue,head)),None)
[OKAY] RuntimeCheck(MethodPost,FieldAccessibilityCheck(Field(Var(q),MinPriorityQueue,size)),None)
[OKAY] RuntimeCheck(MethodPost,FieldSeparationCheck(Field(Result,MinPriorityQueue,head)),None)
[MARKED AS CONDITION] RuntimeCheck(MethodPost,FieldSeparationCheck(Field(Result,MinPriorityQueue,size)),None)
None of them should be marked as condition in the first example.
Of course in the second example there are conditions to analyze with result:
The logic check RuntimeCheck(MethodPost,PredicateAccessibilityCheck(nonEmptyStack,List(Var(s))),Some(NotCondition(ImmediateCondition(Eq(FalseLit,TrueLit)))))
uses the direct condition value from the verifier !(false == true)
The separation check RuntimeCheck(MethodPost,PredicateSeparationCheck(nonEmptyStack,List(Var(s))),Some(ImmediateCondition(Not(Eq(Result,TrueLit)))))
uses the context subbed into the direct condition aka !(result == true)
. The logic check succeeds and the separation check fails when the condition is sent to expr.toIR
with the returnValue
set to None
always.
For this program below,
The verifier outputs this error in the Weaver:
It is because there are 2 run-time checks for accessibility predicates containing
\result
in them. When I remove any one of the accessibility predicates from the postcondition, the error doesn't occur. Same error happens if one of the accessibility predicates is replaced by a predicate that takes\result
as an argument.