Ada.Unchecked_Conversion
A generic function that reads a value's bits as a value of another type (RM 13.9). Verada models it exactly between scalar types stored in the same number of bits: integer, modular, enumeration and floating-point types.
Read the family guide for representation, selection and resource rules. The complete declaration page retains exact signatures/contracts; the source specification is the implementation baseline.
Availability and ownership
No body runs: each call is the conversion itself, in generated code a reinterpretation of the bits, in proof the exact value with those bits (a float's IEEE encoding included). Where not every pattern of bits is a value of the target (a narrower range, fewer enumeration literals, a float's NaNs and infinities), the call checks that these are, and the prover proves the check. The source and target are scalar types of the same size: types stored in different sizes are rejected (B2027), and records and arrays with B7005; convert a composite value component by component.
Import and instantiate
with Ada.Unchecked_Conversion;
...
function To_Bits is new Ada.Unchecked_Conversion (Float, Interfaces.Unsigned_32);API 001
ada.unchecked_conversion (declaration) — The generic function: its formal source and target types, and the conversion from one to the other.
Declared interface:
-- Ada.Unchecked_Conversion (RM 13.9), as Verada models it precisely (G6): between scalar
-- types stored in the same number of bits, the result is the value whose bits are the
-- source's. A target type with bit patterns that are not its values (a range narrower than
-- its storage, an enumeration with fewer literals, a float's NaNs and infinities) gets a
-- check that the bits are a value of it, which the prover proves like any range check.
generic
type Source (<>) is limited private;
type Target (<>) is limited private;
function Ada.Unchecked_Conversion (S : Source) return Target
with Global => null,
Import, Convention => Ada, External_Name => "verada_unchecked_conversion";