DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B3024: a Constant_After_Elaboration variable changed after elaboration

Catalog status: active. Default severity: error. Stable name: constant-after-elaboration. Family: Flow and effects.

A library-level variable with Constant_After_Elaboration may be changed only while its package is elaborated: by its declaration's value, other declarations of the package, or the body's statements. Every subprogram, which may run after elaboration, only reads it. Flow analysis reports a subprogram that may change it (directly or through what it calls).

Example (Vada)

package Counters is
   Limit : Natural := 0 with Constant_After_Elaboration;
   procedure Reset;
end Counters;

package body Counters is
   procedure Reset is
   begin
      Limit := 0;   --  B3024: Reset may run after elaboration
   end Reset;
begin
   Limit := 10;    --  the body's statements may set it
end Counters;

What to do

Set it only during elaboration, or, if it must change later, remove the aspect: then it is an ordinary variable, and what reads it must allow for its changes.

Regression source and further reading

Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.

See flow and effects, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.