DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

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:

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.