DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B3025: variable never used, or assigned but never read

Catalog status: active. Default severity: warning. Stable name: unused-variable. Family: Flow and effects.

A warning from flow analysis: a local variable that nothing reads. Either nothing uses it at all, or it is assigned but its value is never read, so the assignments are wasted. Reads in assertions and contracts count. The program is not wrong; the variable is likely a leftover, or a typo hides the use that was meant.

Example (Vada)

procedure Report (X : Integer) is
   Total : Integer := 0;   --  B3025: never used
   Last  : Integer;        --  B3025: assigned but never read
begin
   Last := X;
end Report;

Example (Varc)

fn report(x: Integer) {
    var last: Integer;   // B3025: assigned but never read
    last = x;
}

What to do

Remove the variable, or use it where it was meant to be used. A variable meant to go unused (an out actual whose value does not matter) can say so: name it in pragma Unreferenced, or give it a name containing Dummy, Discard, Ignore, Junk or Unused (GNAT's convention), or, in Varc and Vibe, one beginning with _.

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.