DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B2031: a record representation clause that places its components illegally

Catalog status: active. Default severity: error. Stable name: record-layout. Family: Types and constraints.

A record representation clause (for R use record ... end record;) says where each component of R is stored: C at P range F .. L puts C in bits F to L counted from the low-order bit of storage unit P. Verada stores the record that way, and 'Size, 'Position, 'First_Bit, 'Last_Bit and Unchecked_Conversion read the same layout, so the clause must describe storage that can hold every value:

Example (Vada)

   type Status is record
      Ready : Boolean;
      Count : Integer range 0 .. 300;
   end record with Size => 16;
   for Status use record
      Ready at 0 range 0 .. 0;
      Count at 0 range 1 .. 8;
   end record;

Count needs 9 bits for 300, and is given 8.

What to do (Vada)

Widen the component's bits, or narrow its subtype to the values the bits hold:

   for Status use record
      Ready at 0 range 0 .. 0;
      Count at 0 range 1 .. 9;
   end record;

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.