DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
B5102: postcondition might fail
Catalog status: active. Default severity: error. Stable name: postcondition. Family: Contracts and termination.
On some path to a return (or the end of a procedure) the prover could not show that the postcondition holds. The counterexample gives inputs for which the postcondition is false.
Example (Vada)
function Maximum (A, B : Integer) return Integer
with Post => Maximum'Result >= A and Maximum'Result >= B
is
begin
if A > B then
return A;
else
return A; -- should be B
end if;
end Maximum;Example (Varc)
fn maximum(a, b: Integer) -> Integer
ensures result >= a && result >= b
{
if a > b {
return a;
} else {
return a; // should be b
}
}
What to do
Fix the body, or correct the postcondition if it promises more than the subprogram does. A loop whose effect the postcondition describes usually needs a loop invariant that carries that effect to the loop's exit.
Regression source and further reading
Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.
See contracts and termination, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.