On this page
B5106: contract cases might not be complete and disjoint
Catalog status: active. Default severity: error. Stable name: contract-cases. Family: Contracts and termination.
Contract_Cases lists guards with the postcondition each one promises. On entry exactly one guard must hold: the cases must not overlap, and they must cover every input the precondition allows. With an others case, at most one of the other guards may hold. The prover found inputs where none or several of the guards hold.
Example (Vada)
function Sign (X : Integer) return Integer
with Contract_Cases => (X >= 0 => Sign'Result = 1,
X <= 0 => Sign'Result = -1); -- both hold when X = 0Example (Varc)
fn sign(x: Integer) -> Integer
cases { x >= 0 => result == 1, x <= 0 => result == -1 }; // both hold when x == 0
What to do (Vada)
Make the guards disjoint (X > 0 and X <= 0 here), add the missing case, or add an others case for the inputs the other guards leave out.
What to do (Varc)
Make the guards disjoint (x > 0 and x <= 0 here), add the missing case, or add an others case for the inputs the other guards leave out.
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.