B2028: a general access value that could outlive, alias or free what it designates
Catalog status: active. Default severity: error. Stable name: general-access-ownership. Family: Types and constraints.
A general access type (access all T) may designate an object that was declared rather than made by new. Verada keeps such values under ownership: the value takes the object for good, so nothing else may reach it, and nothing may free it. That needs four things, each of which this error reports when it is missing:
X'Accessnames a whole object declaredaliased(a part of an object, or what another access value designates, would leave a second path to the same storage);- the object is declared no deeper than the access type, so no value of the type outlives it (RM 3.10.2);
- no instance of
Ada.Unchecked_Deallocationtakes a general access type, since the object it designates may be one the heap never made; newmakes an object for a general access type only at library level, once, since it can never be freed.
Example (Vada)
type Cell_Ref is access all Cell;
R : Cell_Ref;
procedure Inner is
Local : aliased Cell;
begin
R := Local'Access;
end Inner;What to do (Vada)
Declare the object at the access type's level or above, or the access type where the object is:
procedure Inner is
type Local_Ref is access all Cell;
Local : aliased Cell;
R : Local_Ref := Local'Access;
begin
R.Value := 1;
end Inner;Regression source and further reading
Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.
See types and constraints, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.