DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B3028: in out parameter that could be in or out

Catalog status: active. Default severity: warning. Stable name: in-out-mode. Family: Flow and effects.

A warning from flow analysis on an in out parameter: either the subprogram never changes it, so it could be in; or the subprogram never reads the value it has on entry (every path that returns assigns it first), so it could be out. A mode that says more than the subprogram does misleads its callers and its proof: an in out parameter must be initialized by the caller, and is assumed changed by the call.

Modes that are not the subprogram's to choose are not reported: a dispatching operation's (its root's), a subprogram's named by 'Access, or bound to a generic's formal subprogram.

Example (Vada)

procedure Show (Count : in out Natural) is   --  B3028: never changed, could be in
begin
   Log.Put (Count);
end Show;

procedure Reset (Count : in out Natural) is  --  B3028: never read, could be out
begin
   Count := 0;
end Reset;

Example (Varc)

fn reset(count: inout Natural) {   // B3028: never read, could be out
    count = 0;
}

What to do

Change the mode to the one the note names.

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.