DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B3023: volatile object read inside an expression

Catalog status: active. Default severity: error. Stable name: volatile-context. Family: Flow and effects.

An object with Async_Writers (something outside the program may change it) or Effective_Reads (reading it is an effect) is read only where it is the whole value: the value of an assignment, an actual parameter, an object's initial value, or a value returned. Elsewhere, such as an operand of + or a condition, which read happens, and how many, would not be clear. Assign the object to a variable first, and use the variable.

Example (Vada)

   Reading : Integer := 0 with Volatile, Async_Writers;
   ...
      B := Reading + 1;   --  B3023

Example (Varc)

    pub var Reading: Integer = 0 @Volatile @Async_Writers;
    ...
        B = Reading + 1;   // B3023

Fix

      A := Reading;
      B := A + 1;

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.