On this page
B5110: an initial condition might not hold
Catalog status: active. Default severity: error. Stable name: default-initial-condition. Family: Contracts and termination.
A private type's Default_Initial_Condition promises its clients something about every object of the type that is declared without an initial value, such as "a new stack is empty". The prover checks it for each such object against the full type's default values, which it sees, and found that the defaults might not satisfy it.
Example (Vada)
type Counter is private
with Default_Initial_Condition => Value (Counter) = 0;
private
type Counter is record
Count : Natural := 1; -- not 0
end record;Example (Varc)
pub struct Counter @Default_Initial_Condition(value(Counter) == 0) {
count: Natural = 1, // not 0
}
What to do
Give the full type defaults that satisfy the condition, or correct the condition.
A package's Initial_Condition
The same check proves a package's Initial_Condition where its elaboration ends (its body's, when it has one): the main program then knows it, as long as no later elaboration may change what it names. Make the package's declarations or body statements establish it.
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.